← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/DBIx/MultiStatementDo.pm
StatementsExecuted 16 statements in 517µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.34ms6.22msDBIx::MultiStatementDo::::BEGIN@11DBIx::MultiStatementDo::BEGIN@11
1111.29ms291msDBIx::MultiStatementDo::::BEGIN@8DBIx::MultiStatementDo::BEGIN@8
1118µs35µsDBIx::MultiStatementDo::::BEGIN@9DBIx::MultiStatementDo::BEGIN@9
1117µs62µsDBIx::MultiStatementDo::::BEGIN@113DBIx::MultiStatementDo::BEGIN@113
1115µs5µsDBIx::MultiStatementDo::::BEGIN@3DBIx::MultiStatementDo::BEGIN@3
0000s0sDBIx::MultiStatementDo::::__ANON__[:36]DBIx::MultiStatementDo::__ANON__[:36]
0000s0sDBIx::MultiStatementDo::::_do_statementsDBIx::MultiStatementDo::_do_statements
0000s0sDBIx::MultiStatementDo::::_set_splitterDBIx::MultiStatementDo::_set_splitter
0000s0sDBIx::MultiStatementDo::::doDBIx::MultiStatementDo::do
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1## no critic
2package DBIx::MultiStatementDo;
3
# spent 5µs within DBIx::MultiStatementDo::BEGIN@3 which was called: # once (5µs+0s) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 5
BEGIN {
413µs $DBIx::MultiStatementDo::VERSION = '1.00009';
5115µs15µs}
# spent 5µs making 1 call to DBIx::MultiStatementDo::BEGIN@3
6## use critic
7
8270µs2294ms
# spent 291ms (1.29+290) within DBIx::MultiStatementDo::BEGIN@8 which was called: # once (1.29ms+290ms) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 8
use Moose;
# spent 291ms making 1 call to DBIx::MultiStatementDo::BEGIN@8 # spent 2.57ms making 1 call to Moose::import
9222µs262µs
# spent 35µs (8+27) within DBIx::MultiStatementDo::BEGIN@9 which was called: # once (8µs+27µs) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 9
use Carp qw(croak);
# spent 35µs making 1 call to DBIx::MultiStatementDo::BEGIN@9 # spent 27µs making 1 call to Exporter::import
10
113348µs36.23ms
# spent 6.22ms (2.34+3.88) within DBIx::MultiStatementDo::BEGIN@11 which was called: # once (2.34ms+3.88ms) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 11
use SQL::SplitStatement 1.00009;
# spent 6.22ms making 1 call to DBIx::MultiStatementDo::BEGIN@11 # spent 6µs making 1 call to UNIVERSAL::VERSION # spent 2µs making 1 call to Class::Accessor::import
12
131800ns17.30mshas 'dbh' => (
# spent 7.30ms making 1 call to Moose::has
14 is => 'rw',
15 isa => 'DBI::db',
16 required => 1
17);
18
1912µs13.05mshas 'splitter_options' => (
# spent 3.05ms making 1 call to Moose::has
20 is => 'rw',
21 isa => 'Maybe[HashRef[Bool]]',
22 trigger => \&_set_splitter,
23 default => undef
24);
25
26sub _set_splitter {
27 my ($self, $new_options) = @_;
28 $self->_splitter( SQL::SplitStatement->new($new_options) )
29}
30
31has '_splitter' => (
32 is => 'rw',
33 isa => 'SQL::SplitStatement',
34 handles => [ qw(split split_with_placeholders) ],
35 lazy => 1,
36 default => sub { SQL::SplitStatement->new }
3714µs11.84ms);
# spent 1.84ms making 1 call to Moose::has
38
3911µs11.04mshas 'rollback' => (
# spent 1.04ms making 1 call to Moose::has
40 is => 'rw',
41 isa => 'Bool',
42 default => 1
43);
44
45sub do {
46 my ($self, $code, $attr, @bind_values) = @_;
47
48 my ( $statements, $placeholders )
49 = ! ref($code)
50 ? $self->split_with_placeholders($code)
51 : ref( $code->[0] ) eq 'ARRAY'
52 ? @$code
53 : ( $code, undef );
54
55 my @compound_bind_values;
56 if ( @bind_values >= 1 ) {
57 if ( ! ref $bind_values[0] ) {
58 # @bind_values was a FLAT LIST
59 ref($placeholders) ne 'ARRAY' and croak(
60q[Bind values as a flat list require the placeholder numbers listref to be passed as well]
61 );
62 push @compound_bind_values, [ splice @bind_values, 0, $_ ]
63 foreach @$placeholders
64 } else {
65 @compound_bind_values = @{ $bind_values[0] }
66 }
67 }
68
69
70 my $dbh = $self->dbh;
71 my @results;
72
73 if ( $self->rollback ) {
74 local $dbh->{AutoCommit} = 0;
75 local $dbh->{RaiseError} = 1;
76 eval {
77 @results = $self->_do_statements(
78 $statements, $attr, \@compound_bind_values
79 );
80 $dbh->commit;
81 1
82 } or eval {
83 $dbh->rollback
84 }
85 } else {
86 @results = $self->_do_statements(
87 $statements, $attr, \@compound_bind_values
88 )
89 }
90
91 return @results if wantarray; # List context.
92 return 1 if @results == @$statements; # Scalar context and success.
93 return # Scalar context and failure.
94}
95
96sub _do_statements {
97 my ($self, $statements, $attr, $compound_bind_values) = @_;
98
99 my @results;
100 my $dbh = $self->dbh;
101
102 for my $statement ( @$statements ) {
103 my $result = $dbh->do(
104 $statement, $attr, @{ shift(@$compound_bind_values) || [] }
105 );
106 last unless $result;
107 push @results, $result
108 }
109
110 return @results
111}
112
113222µs2118µs
# spent 62µs (7+55) within DBIx::MultiStatementDo::BEGIN@113 which was called: # once (7µs+55µs) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 113
no Moose;
# spent 62µs making 1 call to DBIx::MultiStatementDo::BEGIN@113 # spent 55µs making 1 call to Moose::unimport
11415µs217.3ms__PACKAGE__->meta->make_immutable;
# spent 17.3ms making 1 call to Class::MOP::Class::make_immutable # spent 8µs making 1 call to DBIx::MultiStatementDo::meta
115
116122µs1;
117
118__END__