| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/BenchmarkAnything/Storage/Backend/SQL/Query/mysql.pm |
| Statements | Executed 19047 statements in 98.2ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 4650 | 1 | 1 | 76.1ms | 941ms | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addvaluerelation |
| 1000 | 1 | 1 | 25.0ms | 247ms | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_benchmark_value |
| 5678 | 3 | 1 | 5.01ms | 5.01ms | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_NOW |
| 2000 | 2 | 1 | 4.28ms | 4.28ms | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_FOR_UPDATE |
| 28 | 1 | 1 | 272µs | 4.65ms | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addvalue |
| 1 | 1 | 1 | 10µs | 11µs | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@5 |
| 1 | 1 | 1 | 6µs | 99µs | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@9 |
| 1 | 1 | 1 | 5µs | 2.04ms | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@7 |
| 1 | 1 | 1 | 5µs | 8µs | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::__ANON__[:186] |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::__ANON__[:187] |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::__ANON__[:192] |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::__ANON__[:212] |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::__ANON__[:213] |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::__ANON__[:321] |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::__ANON__[:81] |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::create_select_column |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addtype |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addtyperelation |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_benchmark |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_unit |
| 0 | 0 | 0 | 0s | 0s | BenchmarkAnything::Storage::Backend::SQL::Query::mysql::select_benchmark_values |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package BenchmarkAnything::Storage::Backend::SQL::Query::mysql; | ||||
| 2 | 1 | 300ns | our $AUTHORITY = 'cpan:TAPPER'; | ||
| 3 | # ABSTRACT: BenchmarkAnything::Storage::Backend::SQL - querying - MySQL backend | ||||
| 4 | 1 | 100ns | $BenchmarkAnything::Storage::Backend::SQL::Query::mysql::VERSION = '0.023'; | ||
| 5 | 2 | 18µs | 2 | 13µs | # spent 11µs (10+1) within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@5 which was called:
# once (10µs+1µs) by Module::Load::_load at line 5 # spent 11µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@5
# spent 1µs making 1 call to strict::import |
| 6 | 2 | 14µs | 2 | 11µs | # spent 8µs (5+3) within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@6 which was called:
# once (5µs+3µs) by Module::Load::_load at line 6 # spent 8µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@6
# spent 3µs making 1 call to warnings::import |
| 7 | 2 | 24µs | 2 | 4.08ms | # spent 2.04ms (5µs+2.04) within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@7 which was called:
# once (5µs+2.04ms) by Module::Load::_load at line 7 # spent 2.04ms making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@7
# spent 2.04ms making 1 call to base::import |
| 8 | |||||
| 9 | 2 | 1.11ms | 2 | 192µs | # spent 99µs (6+93) within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@9 which was called:
# once (6µs+93µs) by Module::Load::_load at line 9 # spent 99µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::BEGIN@9
# spent 93µs making 1 call to Exporter::Tiny::import |
| 10 | |||||
| 11 | 1 | 200ns | my %h_used_selects; | ||
| 12 | 1 | 2µs | my %h_default_columns = ( | ||
| 13 | 'NAME' => 'b.bench', | ||||
| 14 | 'UNIT' => 'bu.bench_unit', | ||||
| 15 | 'VALUE' => 'bv.bench_value', | ||||
| 16 | 'VALUE_ID' => 'bv.bench_value_id', | ||||
| 17 | 'CREATED' => 'bv.created_at', | ||||
| 18 | ); | ||||
| 19 | |||||
| 20 | 5678 | 30.6ms | # spent 5.01ms within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_NOW which was called 5678 times, avg 882ns/call:
# 4650 times (3.39ms+0s) by BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addvaluerelation at line 425, avg 729ns/call
# 1000 times (1.60ms+0s) by BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_benchmark_value at line 382, avg 2µs/call
# 28 times (21µs+0s) by BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addvalue at line 410, avg 750ns/call | ||
| 21 | |||||
| 22 | 2000 | 7.35ms | # spent 4.28ms within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_FOR_UPDATE which was called 2000 times, avg 2µs/call:
# 1000 times (2.21ms+0s) by BenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_lock at line 689 of BenchmarkAnything/Storage/Backend/SQL/Query/common.pm, avg 2µs/call
# 1000 times (2.07ms+0s) by BenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_processing at line 704 of BenchmarkAnything/Storage/Backend/SQL/Query/common.pm, avg 2µs/call | ||
| 23 | |||||
| 24 | sub select_benchmark_values { | ||||
| 25 | |||||
| 26 | my ( $or_self, $hr_search ) = @_; | ||||
| 27 | |||||
| 28 | # clear selected columns | ||||
| 29 | $h_used_selects{$or_self} = {}; | ||||
| 30 | |||||
| 31 | # deep copy hash | ||||
| 32 | require JSON::XS; | ||||
| 33 | $hr_search = JSON::XS::decode_json( | ||||
| 34 | JSON::XS::encode_json( $hr_search ) | ||||
| 35 | ); | ||||
| 36 | |||||
| 37 | my ( | ||||
| 38 | $s_limit, | ||||
| 39 | $s_offset, | ||||
| 40 | $s_order_by, | ||||
| 41 | @a_select, | ||||
| 42 | @a_from, | ||||
| 43 | @a_from_vals, | ||||
| 44 | @a_where, | ||||
| 45 | @a_where_vals, | ||||
| 46 | ) = ( | ||||
| 47 | q##, | ||||
| 48 | q##, | ||||
| 49 | q##, | ||||
| 50 | ); | ||||
| 51 | |||||
| 52 | # limit clause | ||||
| 53 | if ( $hr_search->{limit} ) { | ||||
| 54 | if ( $hr_search->{limit} =~ /^\d+$/ ) { | ||||
| 55 | $s_limit = "LIMIT $hr_search->{limit}"; | ||||
| 56 | } | ||||
| 57 | else { | ||||
| 58 | require Carp; | ||||
| 59 | Carp::confess("invalid limit value '$hr_search->{limit}'"); | ||||
| 60 | return; | ||||
| 61 | } | ||||
| 62 | } | ||||
| 63 | |||||
| 64 | # offset clause | ||||
| 65 | if ( $hr_search->{offset} ) { | ||||
| 66 | if ( $hr_search->{offset} =~ /^\d+$/ ) { | ||||
| 67 | $s_offset = "OFFSET $hr_search->{offset}"; | ||||
| 68 | } | ||||
| 69 | else { | ||||
| 70 | require Carp; | ||||
| 71 | Carp::confess("invalid offset value '$hr_search->{offset}'"); | ||||
| 72 | return; | ||||
| 73 | } | ||||
| 74 | } | ||||
| 75 | |||||
| 76 | # where clause | ||||
| 77 | my $i_counter = 0; | ||||
| 78 | if ( $hr_search->{where} ) { | ||||
| 79 | |||||
| 80 | for my $ar_where ( @{$hr_search->{where}} ) { | ||||
| 81 | if ( any { $ar_where->[1] eq $_ } keys %h_default_columns ) { | ||||
| 82 | my $s_column = splice( @{$ar_where}, 1, 1 ); | ||||
| 83 | push @a_where, $or_self->create_where_clause( $h_default_columns{$s_column}, $ar_where ); | ||||
| 84 | push @a_where_vals , @{$ar_where}[1..$#{$ar_where}]; | ||||
| 85 | } | ||||
| 86 | else { | ||||
| 87 | my $s_additional_type = splice( @{$ar_where}, 1, 1 ); | ||||
| 88 | my $hr_additional_type = $or_self | ||||
| 89 | ->select_addtype_by_name( $s_additional_type ) | ||||
| 90 | ->fetchrow_hashref() | ||||
| 91 | ; | ||||
| 92 | if ( !$hr_additional_type || !$hr_additional_type->{bench_additional_type_id} ) { | ||||
| 93 | require Carp; | ||||
| 94 | Carp::confess("benchmark additional value '$s_additional_type' not exists"); | ||||
| 95 | return; | ||||
| 96 | } | ||||
| 97 | push @a_from, " | ||||
| 98 | JOIN ( | ||||
| 99 | $or_self->{config}{tables}{additional_relation_table} bar$i_counter | ||||
| 100 | JOIN $or_self->{config}{tables}{additional_value_table} bav$i_counter | ||||
| 101 | ON ( bav$i_counter.bench_additional_value_id = bar$i_counter.bench_additional_value_id ) | ||||
| 102 | ) | ||||
| 103 | ON ( | ||||
| 104 | bar$i_counter.bench_value_id = bv.bench_value_id | ||||
| 105 | AND bav$i_counter.bench_additional_type_id = ? | ||||
| 106 | ) | ||||
| 107 | "; | ||||
| 108 | push @a_from_vals, $hr_additional_type->{bench_additional_type_id}; | ||||
| 109 | push @a_where, $or_self->create_where_clause( "bav$i_counter.bench_additional_value", $ar_where ); | ||||
| 110 | push @a_where_vals , @{$ar_where}[1..$#{$ar_where}]; | ||||
| 111 | $i_counter++; | ||||
| 112 | } | ||||
| 113 | } | ||||
| 114 | } | ||||
| 115 | |||||
| 116 | # select clause | ||||
| 117 | my $b_aggregate_all = 0; | ||||
| 118 | if ( $hr_search->{select} ) { | ||||
| 119 | for my $i_counter ( 0..$#{$hr_search->{select}} ) { | ||||
| 120 | if ( ref $hr_search->{select}[$i_counter] ne 'ARRAY' ) { | ||||
| 121 | $hr_search->{select}[$i_counter] = ['',$hr_search->{select}[$i_counter]]; | ||||
| 122 | } | ||||
| 123 | elsif ( !$b_aggregate_all && $hr_search->{select}[$i_counter][0] ne q## ) { | ||||
| 124 | $b_aggregate_all = 1; | ||||
| 125 | for my $s_clause (qw/ order_by limit offset /) { | ||||
| 126 | if ( $hr_search->{$s_clause} ) { | ||||
| 127 | require Carp; | ||||
| 128 | Carp::confess("cannot use '$s_clause' with aggregation"); | ||||
| 129 | } | ||||
| 130 | } | ||||
| 131 | } | ||||
| 132 | } | ||||
| 133 | } | ||||
| 134 | push @{$hr_search->{select} ||= []}, map {['',$_]} keys %h_default_columns; | ||||
| 135 | |||||
| 136 | for my $ar_select ( @{$hr_search->{select}} ) { | ||||
| 137 | |||||
| 138 | my ( $s_column, $s_select ) = $or_self->create_select_column( | ||||
| 139 | $ar_select, $i_counter, $b_aggregate_all, | ||||
| 140 | ); | ||||
| 141 | |||||
| 142 | if ( $s_select ) { | ||||
| 143 | |||||
| 144 | push @a_select, $s_select; | ||||
| 145 | |||||
| 146 | if ( $s_column ) { | ||||
| 147 | |||||
| 148 | my $hr_additional_type = $or_self | ||||
| 149 | ->select_addtype_by_name( $s_column ) | ||||
| 150 | ->fetchrow_hashref() | ||||
| 151 | ; | ||||
| 152 | if ( !$hr_additional_type || !$hr_additional_type->{bench_additional_type_id} ) { | ||||
| 153 | require Carp; | ||||
| 154 | Carp::confess("benchmark additional value '$s_column' not exists"); | ||||
| 155 | return; | ||||
| 156 | } | ||||
| 157 | |||||
| 158 | push @a_from_vals, $hr_additional_type->{bench_additional_type_id}; | ||||
| 159 | push @a_from, " | ||||
| 160 | LEFT JOIN ( | ||||
| 161 | $or_self->{config}{tables}{additional_relation_table} bar$i_counter | ||||
| 162 | JOIN $or_self->{config}{tables}{additional_value_table} bav$i_counter | ||||
| 163 | ON ( bav$i_counter.bench_additional_value_id = bar$i_counter.bench_additional_value_id ) | ||||
| 164 | ) | ||||
| 165 | ON ( | ||||
| 166 | bar$i_counter.bench_value_id = bv.bench_value_id | ||||
| 167 | AND bav$i_counter.bench_additional_type_id = ? | ||||
| 168 | ) | ||||
| 169 | "; | ||||
| 170 | $i_counter++; | ||||
| 171 | } | ||||
| 172 | } | ||||
| 173 | |||||
| 174 | } | ||||
| 175 | |||||
| 176 | # order_by clause | ||||
| 177 | if ( $hr_search->{order_by} ) { | ||||
| 178 | my @a_order_by_possible = keys %h_default_columns; | ||||
| 179 | my @a_order_by_direction = qw/ ASC DESC /; | ||||
| 180 | if ( $hr_search->{select} ) { | ||||
| 181 | push @a_order_by_possible, map { $_->[1] } @{$hr_search->{select}}; | ||||
| 182 | } | ||||
| 183 | my @a_order_by; | ||||
| 184 | for my $order_column ( @{$hr_search->{order_by}} ) { | ||||
| 185 | if ( ref $order_column ) { | ||||
| 186 | if ( any { $order_column->[0] eq $_ } @a_order_by_possible ) { | ||||
| 187 | if ( any { $order_column->[1] eq $_ } @a_order_by_direction ) { | ||||
| 188 | my $s_numeric_cast = q##; | ||||
| 189 | if ( $order_column->[2] && $order_column->[2]{numeric} ) { | ||||
| 190 | $s_numeric_cast = '0 + '; | ||||
| 191 | } | ||||
| 192 | if ( any { $order_column->[0] eq $_ } keys %h_default_columns ) { | ||||
| 193 | push @a_order_by, "$s_numeric_cast$h_default_columns{$order_column->[0]} $order_column->[1]"; | ||||
| 194 | } | ||||
| 195 | else { | ||||
| 196 | push @a_order_by, "$s_numeric_cast$order_column->[0] $order_column->[1]"; | ||||
| 197 | } | ||||
| 198 | } | ||||
| 199 | else { | ||||
| 200 | require Carp; | ||||
| 201 | Carp::confess("unknown order by direction '$order_column->[1]'"); | ||||
| 202 | return; | ||||
| 203 | } | ||||
| 204 | } | ||||
| 205 | else { | ||||
| 206 | require Carp; | ||||
| 207 | Carp::confess("unknown order by column '$order_column->[0]'"); | ||||
| 208 | return; | ||||
| 209 | } | ||||
| 210 | } | ||||
| 211 | else { | ||||
| 212 | if ( any { $order_column eq $_ } @a_order_by_possible ) { | ||||
| 213 | if ( any { $order_column eq $_ } keys %h_default_columns ) { | ||||
| 214 | push @a_order_by, "$h_default_columns{$order_column} ASC"; | ||||
| 215 | } | ||||
| 216 | else { | ||||
| 217 | push @a_order_by, "$order_column ASC"; | ||||
| 218 | } | ||||
| 219 | } | ||||
| 220 | else { | ||||
| 221 | require Carp; | ||||
| 222 | Carp::confess("unknown order by column '$order_column'"); | ||||
| 223 | return; | ||||
| 224 | } | ||||
| 225 | } | ||||
| 226 | } | ||||
| 227 | $s_order_by = 'ORDER BY ' . (join ', ', @a_order_by) | ||||
| 228 | } | ||||
| 229 | |||||
| 230 | # replace placeholders inside of raw sql where clause | ||||
| 231 | my $s_raw_where = $hr_search->{where_sql}; | ||||
| 232 | if ( $s_raw_where ) { | ||||
| 233 | $s_raw_where =~ s/ | ||||
| 234 | $h_used_selects{$or_self}{$1} | ||||
| 235 | ? $h_used_selects{$or_self}{$1} | ||||
| 236 | : die "column '$1' not exists in SELECT clause" | ||||
| 237 | /gex; | ||||
| 238 | |||||
| 239 | |||||
| 240 | } | ||||
| 241 | |||||
| 242 | return $or_self->execute_query( | ||||
| 243 | " | ||||
| 244 | SELECT | ||||
| 245 | " . ( join ",\n", map {"$_"} @a_select ) . " | ||||
| 246 | FROM | ||||
| 247 | $or_self->{config}{tables}{benchmark_table} b | ||||
| 248 | JOIN $or_self->{config}{tables}{benchmark_value_table} bv | ||||
| 249 | ON ( bv.bench_id = b.bench_id ) | ||||
| 250 | LEFT JOIN $or_self->{config}{tables}{unit_table} bu | ||||
| 251 | ON ( bu.bench_unit_id = b.bench_unit_id ) | ||||
| 252 | " . ( join "\n", @a_from ) . " | ||||
| 253 | WHERE | ||||
| 254 | b.active = 1 | ||||
| 255 | AND bv.active = 1 | ||||
| 256 | " . | ||||
| 257 | ( @a_where ? join "\n", map { "AND $_" } @a_where : q## ) . | ||||
| 258 | ( $s_raw_where ? " $s_raw_where" : q## ) . | ||||
| 259 | " | ||||
| 260 | $s_order_by | ||||
| 261 | $s_limit | ||||
| 262 | $s_offset | ||||
| 263 | ", | ||||
| 264 | @a_from_vals, | ||||
| 265 | @a_where_vals, | ||||
| 266 | ); | ||||
| 267 | |||||
| 268 | } | ||||
| 269 | |||||
| 270 | sub create_select_column { | ||||
| 271 | |||||
| 272 | my ( $or_self, $ar_select, $i_counter, $b_aggregate_all ) = @_; | ||||
| 273 | |||||
| 274 | my $s_aggr_func = q##; | ||||
| 275 | my ( $s_aggr, $s_column ) = @{$ar_select}; | ||||
| 276 | my $s_return_select = q##; | ||||
| 277 | |||||
| 278 | AGGR: { | ||||
| 279 | if ( $s_aggr eq q## ) { | ||||
| 280 | # aggregate all columns if a single column is aggregated | ||||
| 281 | if ( $b_aggregate_all ) { | ||||
| 282 | $s_aggr = $or_self->{config}{default_aggregation}; | ||||
| 283 | redo AGGR; | ||||
| 284 | } | ||||
| 285 | $s_return_select = '${COLUMN}'; | ||||
| 286 | } | ||||
| 287 | elsif ( $s_aggr eq 'min' ) { | ||||
| 288 | $s_return_select = 'MIN( 0 + ${COLUMN} )'; | ||||
| 289 | } | ||||
| 290 | elsif ( $s_aggr eq 'max' ) { | ||||
| 291 | $s_return_select = 'MAX( 0 + ${COLUMN} )'; | ||||
| 292 | } | ||||
| 293 | elsif ( $s_aggr eq 'avg' ) { | ||||
| 294 | $s_return_select = 'AVG( 0 + ${COLUMN} )'; | ||||
| 295 | } | ||||
| 296 | elsif ( $s_aggr eq 'gem' ) { | ||||
| 297 | $s_return_select = 'EXP( SUM( LOG( ${COLUMN} ) ) / COUNT( ${COLUMN} ) )'; | ||||
| 298 | } | ||||
| 299 | elsif ( $s_aggr eq 'sum' ) { | ||||
| 300 | $s_return_select = 'SUM( 0 + ${COLUMN} )'; | ||||
| 301 | } | ||||
| 302 | elsif ( $s_aggr eq 'cnt' ) { | ||||
| 303 | $s_return_select = 'COUNT( ${COLUMN} )'; | ||||
| 304 | } | ||||
| 305 | elsif ( $s_aggr eq 'cnd' ) { | ||||
| 306 | $s_return_select = 'COUNT( DISTINCT ${COLUMN} )'; | ||||
| 307 | } | ||||
| 308 | else { | ||||
| 309 | require Carp; | ||||
| 310 | Carp::confess("unknown aggregate function '$s_aggr'"); | ||||
| 311 | return; | ||||
| 312 | } | ||||
| 313 | } # AGGR | ||||
| 314 | |||||
| 315 | my ( $s_return_column ); | ||||
| 316 | my $s_replace_as = $s_aggr ? $s_aggr . "_$s_column" : $s_column; | ||||
| 317 | |||||
| 318 | if ( $h_used_selects{$or_self}{$s_replace_as} ) { | ||||
| 319 | return; | ||||
| 320 | } | ||||
| 321 | if ( any { $s_column eq $_ } keys %h_default_columns ) { | ||||
| 322 | $h_used_selects{$or_self}{$s_replace_as} = $h_default_columns{$s_column}; | ||||
| 323 | } | ||||
| 324 | else { | ||||
| 325 | $s_return_column = $s_column; | ||||
| 326 | $h_used_selects{$or_self}{$s_replace_as} = "bav$i_counter.bench_additional_value"; | ||||
| 327 | } | ||||
| 328 | |||||
| 329 | $s_return_select =~ s/\$\{COLUMN\}/$h_used_selects{$or_self}{$s_replace_as}/g; | ||||
| 330 | |||||
| 331 | return ( $s_return_column, "$s_return_select AS '$s_replace_as'", ); | ||||
| 332 | |||||
| 333 | } | ||||
| 334 | |||||
| 335 | sub insert_addtyperelation { | ||||
| 336 | |||||
| 337 | my ( $or_self, @a_vals ) = @_; | ||||
| 338 | |||||
| 339 | return $or_self->execute_query( " | ||||
| 340 | INSERT IGNORE INTO $or_self->{config}{tables}{additional_type_relation_table} | ||||
| 341 | ( bench_id, bench_additional_type_id, created_at ) | ||||
| 342 | VALUES | ||||
| 343 | ( ?, ?, @{[$or_self->_NOW]} ) | ||||
| 344 | ", @a_vals ); | ||||
| 345 | |||||
| 346 | } | ||||
| 347 | |||||
| 348 | sub insert_unit { | ||||
| 349 | |||||
| 350 | my ( $or_self, @a_vals ) = @_; | ||||
| 351 | |||||
| 352 | return $or_self->execute_query( " | ||||
| 353 | INSERT INTO $or_self->{config}{tables}{unit_table} | ||||
| 354 | ( bench_unit, created_at ) | ||||
| 355 | VALUES | ||||
| 356 | ( ?, @{[$or_self->_NOW]} ) | ||||
| 357 | ON DUPLICATE KEY | ||||
| 358 | UPDATE bench_unit_id=LAST_INSERT_ID(bench_unit_id) | ||||
| 359 | ", @a_vals ); | ||||
| 360 | |||||
| 361 | } | ||||
| 362 | |||||
| 363 | sub insert_benchmark { | ||||
| 364 | |||||
| 365 | my ( $or_self, @a_vals ) = @_; | ||||
| 366 | |||||
| 367 | return $or_self->execute_query( " | ||||
| 368 | INSERT INTO $or_self->{config}{tables}{benchmark_table} | ||||
| 369 | ( bench, bench_unit_id, active, created_at ) | ||||
| 370 | VALUES | ||||
| 371 | ( ?, ?, 1, @{[$or_self->_NOW]} ) | ||||
| 372 | ON DUPLICATE KEY | ||||
| 373 | UPDATE bench_id=LAST_INSERT_ID(bench_id) | ||||
| 374 | ", @a_vals ); | ||||
| 375 | |||||
| 376 | } | ||||
| 377 | |||||
| 378 | # spent 247ms (25.0+222) within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_benchmark_value which was called 1000 times, avg 247µs/call:
# 1000 times (25.0ms+222ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 256 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 247µs/call | ||||
| 379 | |||||
| 380 | 1000 | 1.10ms | my ( $or_self, @a_vals ) = @_; | ||
| 381 | |||||
| 382 | 1000 | 14.1ms | 3000 | 224ms | return $or_self->execute_query( " # spent 220ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 220µs/call
# spent 2.18ms making 1000 calls to DBI::common::STORE, avg 2µs/call
# spent 1.60ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_NOW, avg 2µs/call |
| 383 | INSERT IGNORE INTO $or_self->{config}{tables}{benchmark_value_table} | ||||
| 384 | ( bench_id, bench_subsume_type_id, bench_value, active, created_at ) | ||||
| 385 | VALUES | ||||
| 386 | ( ?, ?, ?, 1, @{[$or_self->_NOW]} ) | ||||
| 387 | ", @a_vals ); | ||||
| 388 | |||||
| 389 | } | ||||
| 390 | |||||
| 391 | sub insert_addtype { | ||||
| 392 | |||||
| 393 | my ( $or_self, @a_vals ) = @_; | ||||
| 394 | |||||
| 395 | return $or_self->execute_query( " | ||||
| 396 | INSERT IGNORE INTO $or_self->{config}{tables}{additional_type_table} | ||||
| 397 | ( bench_additional_type, created_at ) | ||||
| 398 | VALUES | ||||
| 399 | ( ?, @{[$or_self->_NOW]} ) | ||||
| 400 | ON DUPLICATE KEY | ||||
| 401 | UPDATE bench_additional_type_id=LAST_INSERT_ID(bench_additional_type_id) | ||||
| 402 | ", @a_vals ); | ||||
| 403 | |||||
| 404 | } | ||||
| 405 | |||||
| 406 | # spent 4.65ms (272µs+4.38) within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addvalue which was called 28 times, avg 166µs/call:
# 28 times (272µs+4.38ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 334 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 166µs/call | ||||
| 407 | |||||
| 408 | 28 | 23µs | my ( $or_self, @a_vals ) = @_; | ||
| 409 | |||||
| 410 | 28 | 196µs | 84 | 4.44ms | return $or_self->execute_query( " # spent 4.36ms making 28 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 156µs/call
# spent 63µs making 28 calls to DBI::common::STORE, avg 2µs/call
# spent 21µs making 28 calls to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_NOW, avg 750ns/call |
| 411 | INSERT INTO $or_self->{config}{tables}{additional_value_table} | ||||
| 412 | ( bench_additional_type_id, bench_additional_value, created_at ) | ||||
| 413 | VALUES | ||||
| 414 | ( ?, ?, @{[$or_self->_NOW]} ) | ||||
| 415 | ON DUPLICATE KEY | ||||
| 416 | UPDATE bench_additional_value_id=LAST_INSERT_ID(bench_additional_value_id) | ||||
| 417 | ", @a_vals ); | ||||
| 418 | |||||
| 419 | } | ||||
| 420 | |||||
| 421 | # spent 941ms (76.1+865) within BenchmarkAnything::Storage::Backend::SQL::Query::mysql::insert_addvaluerelation which was called 4650 times, avg 202µs/call:
# 4650 times (76.1ms+865ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 348 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 202µs/call | ||||
| 422 | |||||
| 423 | 4650 | 3.26ms | my ( $or_self, @a_vals ) = @_; | ||
| 424 | |||||
| 425 | 4650 | 40.4ms | 13950 | 874ms | return $or_self->execute_query( " # spent 862ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 185µs/call
# spent 8.64ms making 4650 calls to DBI::common::STORE, avg 2µs/call
# spent 3.39ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_NOW, avg 729ns/call |
| 426 | INSERT IGNORE INTO $or_self->{config}{tables}{additional_relation_table} | ||||
| 427 | ( bench_value_id, bench_additional_value_id, active, created_at ) | ||||
| 428 | VALUES | ||||
| 429 | ( ?, ?, 1, @{[$or_self->_NOW]} ) | ||||
| 430 | ", @a_vals ); | ||||
| 431 | |||||
| 432 | } | ||||
| 433 | |||||
| 434 | 1 | 3µs | 1; | ||
| 435 | |||||
| 436 | __END__ |