← 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:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/BenchmarkAnything/Storage/Backend/SQL/Query/common.pm
StatementsExecuted 44915 statements in 218ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
46501151.2ms651msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_addvalueBenchmarkAnything::Storage::Backend::SQL::Query::common::select_addvalue
46501133.7ms676msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_addtyperelationBenchmarkAnything::Storage::Backend::SQL::Query::common::select_addtyperelation
46501128.0ms646msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_addtypeBenchmarkAnything::Storage::Backend::SQL::Query::common::select_addtype
10001126.2ms251msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_raw_bench_bundle_for_processingBenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_processing
10001120.8ms406msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_raw_bench_bundle_for_lockBenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_lock
10001120.7ms230msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_benchmark_point_essentialsBenchmarkAnything::Storage::Backend::SQL::Query::common::select_benchmark_point_essentials
10001114.0ms180msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_benchmarkBenchmarkAnything::Storage::Backend::SQL::Query::common::select_benchmark
1000118.21ms673msBenchmarkAnything::Storage::Backend::SQL::Query::common::::update_raw_bench_bundle_set_processedBenchmarkAnything::Storage::Backend::SQL::Query::common::update_raw_bench_bundle_set_processed
1000116.56ms534msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_complete_benchmark_pointBenchmarkAnything::Storage::Backend::SQL::Query::common::select_complete_benchmark_point
1000116.36ms150msBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_min_subsume_typeBenchmarkAnything::Storage::Backend::SQL::Query::common::select_min_subsume_type
1000115.55ms335msBenchmarkAnything::Storage::Backend::SQL::Query::common::::start_processing_raw_bench_bundleBenchmarkAnything::Storage::Backend::SQL::Query::common::start_processing_raw_bench_bundle
11112µs23.5msBenchmarkAnything::Storage::Backend::SQL::Query::common::::delete_processed_raw_bench_bundlesBenchmarkAnything::Storage::Backend::SQL::Query::common::delete_processed_raw_bench_bundles
1118µs9µsBenchmarkAnything::Storage::Backend::SQL::Query::common::::BEGIN@5BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@5
1118µs146µsBenchmarkAnything::Storage::Backend::SQL::Query::common::::BEGIN@9BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@9
1116µs407µsBenchmarkAnything::Storage::Backend::SQL::Query::common::::BEGIN@7BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@7
1114µs7µsBenchmarkAnything::Storage::Backend::SQL::Query::common::::BEGIN@6BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@6
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::_FOR_UPDATEBenchmarkAnything::Storage::Backend::SQL::Query::common::_FOR_UPDATE
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::_NOWBenchmarkAnything::Storage::Backend::SQL::Query::common::_NOW
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::benchmark_operatorsBenchmarkAnything::Storage::Backend::SQL::Query::common::benchmark_operators
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::copy_additional_valuesBenchmarkAnything::Storage::Backend::SQL::Query::common::copy_additional_values
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::copy_benchmark_backup_additional_relationsBenchmarkAnything::Storage::Backend::SQL::Query::common::copy_benchmark_backup_additional_relations
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::copy_benchmark_backup_valueBenchmarkAnything::Storage::Backend::SQL::Query::common::copy_benchmark_backup_value
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::create_period_checkBenchmarkAnything::Storage::Backend::SQL::Query::common::create_period_check
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::create_where_clauseBenchmarkAnything::Storage::Backend::SQL::Query::common::create_where_clause
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::default_columnsBenchmarkAnything::Storage::Backend::SQL::Query::common::default_columns
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::delete_benchmark_additional_relationsBenchmarkAnything::Storage::Backend::SQL::Query::common::delete_benchmark_additional_relations
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::delete_benchmark_valueBenchmarkAnything::Storage::Backend::SQL::Query::common::delete_benchmark_value
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::insert_raw_bench_bundleBenchmarkAnything::Storage::Backend::SQL::Query::common::insert_raw_bench_bundle
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_additional_key_idBenchmarkAnything::Storage::Backend::SQL::Query::common::select_additional_key_id
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_additional_keysBenchmarkAnything::Storage::Backend::SQL::Query::common::select_additional_keys
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_addtype_by_nameBenchmarkAnything::Storage::Backend::SQL::Query::common::select_addtype_by_name
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_benchmark_namesBenchmarkAnything::Storage::Backend::SQL::Query::common::select_benchmark_names
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_check_subsumed_valuesBenchmarkAnything::Storage::Backend::SQL::Query::common::select_check_subsumed_values
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_count_datapointkeysBenchmarkAnything::Storage::Backend::SQL::Query::common::select_count_datapointkeys
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_count_datapointsBenchmarkAnything::Storage::Backend::SQL::Query::common::select_count_datapoints
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_count_keysBenchmarkAnything::Storage::Backend::SQL::Query::common::select_count_keys
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_count_metricsBenchmarkAnything::Storage::Backend::SQL::Query::common::select_count_metrics
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_data_values_for_subsumeBenchmarkAnything::Storage::Backend::SQL::Query::common::select_data_values_for_subsume
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_multiple_benchmark_points_additionalsBenchmarkAnything::Storage::Backend::SQL::Query::common::select_multiple_benchmark_points_additionals
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_multiple_benchmark_points_essentialsBenchmarkAnything::Storage::Backend::SQL::Query::common::select_multiple_benchmark_points_essentials
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_subsume_typeBenchmarkAnything::Storage::Backend::SQL::Query::common::select_subsume_type
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::select_unitBenchmarkAnything::Storage::Backend::SQL::Query::common::select_unit
0000s0sBenchmarkAnything::Storage::Backend::SQL::Query::common::::update_benchmark_backup_valueBenchmarkAnything::Storage::Backend::SQL::Query::common::update_benchmark_backup_value
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package BenchmarkAnything::Storage::Backend::SQL::Query::common;
21300nsour $AUTHORITY = 'cpan:TAPPER';
3# ABSTRACT: BenchmarkAnything::Storage::Backend::SQL - querying - backend base class
41100ns$BenchmarkAnything::Storage::Backend::SQL::Query::common::VERSION = '0.023';
5216µs210µs
# spent 9µs (8+1) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@5 which was called: # once (8µs+1µs) by base::import at line 5
use strict;
# spent 9µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@5 # spent 1µs making 1 call to strict::import
6213µs29µs
# spent 7µs (4+2) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@6 which was called: # once (4µs+2µs) by base::import at line 6
use warnings;
# spent 7µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@6 # spent 2µs making 1 call to warnings::import
7220µs2407µs
# spent 407µs (6+401) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@7 which was called: # once (6µs+401µs) by base::import at line 7
use base 'BenchmarkAnything::Storage::Backend::SQL::Query';
# spent 407µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@7 # spent 401µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 401µs
8
921.33ms2284µs
# spent 146µs (8+138) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@9 which was called: # once (8µs+138µs) by base::import at line 9
use List::MoreUtils qw( any );
# spent 146µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@9 # spent 138µs making 1 call to Exporter::Tiny::import
10
111200nsmy %h_used_selects;
1212µsmy %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
20sub _NOW { "CURRENT_TIMESTAMP" }
21
22sub _FOR_UPDATE { "FOR UPDATE" }
23
24sub default_columns {
25 return %h_default_columns;
26}
27
28sub benchmark_operators {
29 return ( '=', '!=', 'like', 'not like', '<', '>', '<=', '>=' );
30}
31
32sub create_where_clause {
33
34 my ( $or_self, $s_column_name, $ar_value ) = @_;
35
36 my $s_where_clause = q##;
37 if ( $ar_value->[0] eq 'not like' ) {
38 $s_where_clause = "$s_column_name NOT LIKE ?";
39 }
40 elsif ( $ar_value->[0] eq 'like' ) {
41 $s_where_clause = "$s_column_name LIKE ?";
42 }
43 elsif (
44 $ar_value->[0] eq '<'
45 || $ar_value->[0] eq '>'
46 || $ar_value->[0] eq '<='
47 || $ar_value->[0] eq '>='
48 ) {
49 $s_where_clause = "$s_column_name $ar_value->[0] ?";
50 }
51 elsif ( $ar_value->[0] eq '=' ) {
52 if ( $#{$ar_value} > 1 ) {
53 $s_where_clause = "$s_column_name IN (" . (join ',', map {'?'} 2..@{$ar_value}) . ')';
54 }
55 else {
56 $s_where_clause = "$s_column_name = ?";
57 }
58 }
59 elsif ( $ar_value->[0] eq '!=' ) {
60 if ( $#{$ar_value} > 1 ) {
61 $s_where_clause = "$s_column_name NOT IN (" . (join ',', map {'?'} 2..@{$ar_value}) . ')';
62 }
63 else {
64 $s_where_clause = "$s_column_name != ?";
65 }
66 }
67 else {
68 require Carp;
69 Carp::confess("unknown operator '$ar_value->[0]'");
70 return;
71 }
72
73 return $s_where_clause;
74
75}
76
77sub create_period_check {
78
79 my ( $or_self, $s_column, $dt_from, $dt_to ) = @_;
80
81 my @a_vals;
82 my $s_where;
83 if ( $dt_from ) {
84 if ( my ( $s_date, $s_time ) = $dt_from =~ /(\d{4}-\d{2}-\d{2})( \d{2}:\d{2}:\d{2})?/ ) {
85 $s_where .= "\nAND $s_column > ?";
86 push @a_vals, $s_date . ( $s_time || ' 00:00:00' );
87 }
88 else {
89 require Carp;
90 Carp::confess(q#unknown date format for 'date_from'#);
91 return;
92 }
93 }
94 if ( $dt_to ) {
95 if ( my ( $s_date, $s_time ) = $dt_to =~ /(\d{4}-\d{2}-\d{2})( \d{2}:\d{2}:\d{2})?/ ) {
96 $s_where .= "\nAND $s_column < ?";
97 push @a_vals, $s_date . ( $s_time || ' 23:59:59' );
98 }
99 else {
100 require Carp;
101 Carp::confess(q#unknown date format for 'date_to'#);
102 return;
103 }
104 }
105
106 return {
107 vals => \@a_vals,
108 where => $s_where,
109 };
110
111}
112
113
# spent 230ms (20.7+209) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_benchmark_point_essentials which was called 1000 times, avg 230µs/call: # 1000 times (20.7ms+209ms) by BenchmarkAnything::Storage::Backend::SQL::get_single_benchmark_point at line 647 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 230µs/call
sub select_benchmark_point_essentials {
114
1151000866µs my ( $or_self, @a_vals ) = @_;
116
11710007.69ms2000211ms return $or_self->execute_query( "
# spent 209ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 209µs/call # spent 2.05ms making 1000 calls to DBI::common::STORE, avg 2µs/call
118 SELECT
119 b.bench,
120 bv.created_at,
121 bv.bench_value,
122 bv.bench_value_id,
123 bu.bench_unit
124 FROM
125 $or_self->{config}{tables}{benchmark_table} b
126 JOIN
127 $or_self->{config}{tables}{benchmark_value_table} bv
128 ON
129 b.bench_id = bv.bench_id
130 LEFT JOIN
131 $or_self->{config}{tables}{unit_table} bu
132 ON
133 b.bench_unit_id = bu.bench_unit_id
134 WHERE
135 bv.bench_value_id = ?
136 ;
137 ", @a_vals );
138
139}
140
141
# spent 534ms (6.56+527) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_complete_benchmark_point which was called 1000 times, avg 534µs/call: # 1000 times (6.56ms+527ms) by BenchmarkAnything::Storage::Backend::SQL::get_single_benchmark_point at line 642 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 534µs/call
sub select_complete_benchmark_point {
142
1431000686µs my ( $or_self, @a_vals ) = @_;
144
1451000738µs my $query = "
146 SELECT
147 bat.bench_additional_type,
148 bav.bench_additional_value
149 FROM
150 benchs b
151 JOIN
152 bench_values bv
153 ON
154 b.bench_id = bv.bench_id
155 JOIN
156 bench_additional_type_relations batr
157 ON
158 bv.bench_id = batr.bench_id
159 JOIN
160 bench_additional_types bat
161 ON
162 batr.bench_additional_type_id = bat.bench_additional_type_id
163 JOIN
164 bench_additional_relations bar
165 ON
166 bv.bench_value_id = bar.bench_value_id
167 JOIN
168 bench_additional_values bav
169 ON
170 bar.bench_additional_value_id = bav.bench_additional_value_id AND
171 bat.bench_additional_type_id = bav.bench_additional_type_id
172 WHERE
173 bv.bench_value_id = ?
174 ORDER BY
175 bat.bench_additional_type";
17610004.20ms2000530ms return $or_self->execute_query( $query, @a_vals );
# spent 527ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 527µs/call # spent 2.63ms making 1000 calls to DBI::common::STORE, avg 3µs/call
177}
178
179sub select_multiple_benchmark_points_additionals {
180
181 my ( $or_self, $i_start, $i_count ) = @_;
182
183 my $i_to = $i_start + $i_count;
184
185 my $query = "
186 SELECT
187 bv.bench_value_id,
188 bat.bench_additional_type,
189 bav.bench_additional_value
190 FROM
191 benchs b
192 JOIN
193 bench_values bv
194 ON
195 b.bench_id = bv.bench_id
196 JOIN
197 bench_additional_type_relations batr
198 ON
199 bv.bench_id = batr.bench_id
200 JOIN
201 bench_additional_types bat
202 ON
203 batr.bench_additional_type_id = bat.bench_additional_type_id
204 JOIN
205 bench_additional_relations bar
206 ON
207 bv.bench_value_id = bar.bench_value_id
208 JOIN
209 bench_additional_values bav
210 ON
211 bar.bench_additional_value_id = bav.bench_additional_value_id AND
212 bat.bench_additional_type_id = bav.bench_additional_type_id
213 WHERE
214 bv.bench_value_id >= ? AND
215 bv.bench_value_id < ?
216 ORDER BY
217 bat.bench_additional_type";
218 return $or_self->execute_query( $query, $i_start, $i_to );
219}
220
221sub select_multiple_benchmark_points_essentials {
222
223 my ( $or_self, $i_start, $i_count ) = @_;
224
225 my $i_to = $i_start + $i_count;
226
227 return $or_self->execute_query( "
228 SELECT
229 b.bench,
230 bv.created_at,
231 bv.bench_value,
232 bv.bench_value_id,
233 bu.bench_unit
234 FROM
235 $or_self->{config}{tables}{benchmark_table} b
236 JOIN
237 $or_self->{config}{tables}{benchmark_value_table} bv
238 ON
239 b.bench_id = bv.bench_id
240 LEFT JOIN
241 $or_self->{config}{tables}{unit_table} bu
242 ON
243 b.bench_unit_id = bu.bench_unit_id
244 WHERE
245 bv.bench_value_id >= ? AND
246 bv.bench_value_id < ?
247 ;
248 ", $i_start, $i_to );
249
250}
251
252sub select_addtype_by_name {
253
254 my ( $or_self, @a_vals ) = @_;
255
256 return $or_self->execute_query( "
257 SELECT bench_additional_type_id
258 FROM $or_self->{config}{tables}{additional_type_table}
259 WHERE bench_additional_type = ?
260 ", @a_vals );
261
262}
263
264
# spent 150ms (6.36+144) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_min_subsume_type which was called 1000 times, avg 150µs/call: # 1000 times (6.36ms+144ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 238 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 150µs/call
sub select_min_subsume_type {
265
2661000906µs my ( $or_self, @a_vals ) = @_;
267
26810004.91ms2000146ms return $or_self->execute_query( "
# spent 144ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 144µs/call # spent 1.81ms making 1000 calls to DBI::common::STORE, avg 2µs/call
269 SELECT bench_subsume_type_id
270 FROM $or_self->{config}{tables}{subsume_type_table}
271 ORDER BY bench_subsume_type_rank ASC
272 LIMIT 1
273 " );
274
275}
276
277sub select_subsume_type {
278
279 my ( $or_self, @a_vals ) = @_;
280
281 return $or_self->execute_query( "
282 SELECT
283 bench_subsume_type_id,
284 bench_subsume_type_rank,
285 datetime_strftime_pattern
286 FROM
287 $or_self->{config}{tables}{subsume_type_table}
288 WHERE
289 bench_subsume_type = ?
290 ", @a_vals );
291
292}
293
294sub select_check_subsumed_values {
295
296 my ( $or_self, $hr_vals ) = @_;
297
298 if (! $hr_vals->{subsume_type_id} ) {
299 require Carp;
300 Carp::confess(q#required parameter 'subsume_type_id' is missing#);
301 return;
302 }
303
304 my $hr_period_check = $or_self->create_period_check(
305 'bv.created_at', $hr_vals->{date_from}, $hr_vals->{date_to}
306 );
307
308 return $or_self->execute_query(
309 "
310 SELECT
311 bv.bench_value_id
312 FROM
313 bench_values bv
314 JOIN bench_subsume_types bet
315 ON ( bv.bench_subsume_type_id = bet.bench_subsume_type_id )
316 WHERE
317 bet.bench_subsume_type_rank > (
318 SELECT beti.bench_subsume_type_rank
319 FROM bench_subsume_types beti
320 WHERE bench_subsume_type_id = ?
321 )
322 $hr_period_check->{where}
323 LIMIT
324 1
325 ",
326 $hr_vals->{subsume_type_id},
327 @{$hr_period_check->{vals}},
328 );
329
330}
331
332sub select_data_values_for_subsume {
333
334 my ( $or_self, $hr_vals ) = @_;
335
336 my $hr_period_check = $or_self->create_period_check(
337 'bv.created_at', $hr_vals->{date_from}, $hr_vals->{date_to}
338 );
339
340 my @a_addexclude_vals;
341 my $s_addexclude_where = q##;
342 if ( $hr_vals->{exclude_additionals} && @{$hr_vals->{exclude_additionals}} ) {
343 $s_addexclude_where = 'AND bav.bench_additional_type_id NOT IN (' . (join ',', map {'?'} @{$hr_vals->{exclude_additionals}}) . ')';
344 push @a_addexclude_vals, @{$hr_vals->{exclude_additionals}};
345 }
346
347 return $or_self->execute_query(
348 "
349 SELECT
350 b.bench_id,
351 bv.bench_value_id,
352 bv.created_at,
353 bv.bench_value,
354 bet.bench_subsume_type_rank,
355 GROUP_CONCAT(
356 bav.bench_additional_type_id,
357 '|',
358 bav.bench_additional_value_id
359 ORDER BY
360 bav.bench_additional_type_id,
361 bav.bench_additional_value_id
362 SEPARATOR
363 '-'
364 ) AS additionals
365 FROM
366 benchs b
367 JOIN bench_values bv
368 ON ( bv.bench_id = b.bench_id )
369 JOIN bench_subsume_types bet
370 ON ( bet.bench_subsume_type_id = bv.bench_subsume_type_id )
371 LEFT JOIN (
372 bench_additional_relations bar
373 JOIN bench_additional_values bav
374 ON ( bav.bench_additional_value_id = bar.bench_additional_value_id )
375 )
376 ON (
377 bar.active = 1
378 AND bar.bench_value_id = bv.bench_value_id
379 $s_addexclude_where
380 )
381 WHERE
382 b.active = 1
383 AND bv.active = 1
384 $hr_period_check->{where}
385 GROUP BY
386 bet.bench_subsume_type_rank,
387 b.bench_id,
388 bv.created_at,
389 bv.bench_value,
390 bv.bench_value_id
391 ORDER BY
392 b.bench_id,
393 additionals,
394 bv.created_at
395 ",
396 @a_addexclude_vals,
397 @{$hr_period_check->{vals}},
398 );
399}
400
401
# spent 180ms (14.0+167) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_benchmark which was called 1000 times, avg 180µs/call: # 1000 times (14.0ms+167ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 186 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 180µs/call
sub select_benchmark {
402
4031000909µs my ( $or_self, @a_vals ) = @_;
404
40510006.43ms2000169ms return $or_self->execute_query( "
# spent 167ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 167µs/call # spent 1.98ms making 1000 calls to DBI::common::STORE, avg 2µs/call
406 SELECT bench_id
407 FROM $or_self->{config}{tables}{benchmark_table}
408 WHERE bench = ?
409 ", @a_vals );
410
411}
412
413sub select_benchmark_names {
414
415 my ( $or_self, @a_vals ) = @_;
416
417 my $query = "
418 SELECT DISTINCT bench
419 FROM $or_self->{config}{tables}{benchmark_table}";
420 $query .= "
421 WHERE bench LIKE ? " if @a_vals;
422 return $or_self->execute_query( $query, @a_vals );
423
424}
425
426sub select_additional_keys {
427
428 my ( $or_self, @a_vals ) = @_;
429
430 my $query = "
431 SELECT DISTINCT bench_additional_type
432 FROM $or_self->{config}{tables}{additional_type_table}";
433 $query .= "
434 WHERE bench_additional_type LIKE ? " if @a_vals;
435 return $or_self->execute_query( $query, @a_vals );
436
437}
438
439sub select_additional_key_id {
440
441 my ( $or_self, @a_vals ) = @_;
442
443 return $or_self->execute_query( "
444 SELECT DISTINCT bench_additional_type_id
445 FROM $or_self->{config}{tables}{additional_type_table}
446 WHERE bench_additional_type = ?
447 ", @a_vals );
448
449}
450
451sub select_count_datapoints {
452 my ( $or_self, @a_vals ) = @_;
453
454 return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{benchmark_value_table}" );
455}
456
457sub select_count_metrics {
458 my ( $or_self, @a_vals ) = @_;
459
460 return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{benchmark_table}" );
461}
462
463sub select_count_keys {
464 my ( $or_self, @a_vals ) = @_;
465
466 return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{additional_type_table}" );
467}
468
469sub select_count_datapointkeys {
470 my ( $or_self, @a_vals ) = @_;
471
472 return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{additional_relation_table}" );
473}
474
475sub select_unit {
476
477 my ( $or_self, @a_vals ) = @_;
478
479 return $or_self->execute_query( "
480 SELECT bench_unit_id
481 FROM $or_self->{config}{tables}{unit_table}
482 WHERE bench_unit = ?
483 ", @a_vals );
484
485}
486
487
# spent 646ms (28.0+618) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_addtype which was called 4650 times, avg 139µs/call: # 4650 times (28.0ms+618ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 274 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 139µs/call
sub select_addtype {
488
48946503.15ms my ( $or_self, @a_vals ) = @_;
490
491465022.5ms9300627ms return $or_self->execute_query( "
# spent 618ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 133µs/call # spent 8.37ms making 4650 calls to DBI::common::STORE, avg 2µs/call
492 SELECT bench_additional_type_id
493 FROM $or_self->{config}{tables}{additional_type_table}
494 WHERE bench_additional_type = ?
495 ", @a_vals );
496
497}
498
499
# spent 651ms (51.2+600) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_addvalue which was called 4650 times, avg 140µs/call: # 4650 times (51.2ms+600ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 325 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 140µs/call
sub select_addvalue {
500
50146503.54ms my ( $or_self, @a_vals ) = @_;
502
503465069.0ms9300608ms return $or_self->execute_query( "
# spent 600ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 129µs/call # spent 8.08ms making 4650 calls to DBI::common::STORE, avg 2µs/call
504 SELECT bench_additional_value_id
505 FROM $or_self->{config}{tables}{additional_value_table}
506 WHERE bench_additional_type_id = ? AND bench_additional_value ".(defined($a_vals[1]) ? '= ?' : 'IS NULL')."
507 ", @a_vals );
508
509}
510
511
# spent 676ms (33.7+642) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_addtyperelation which was called 4650 times, avg 145µs/call: # 4650 times (33.7ms+642ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 304 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 145µs/call
sub select_addtyperelation {
512
51346503.72ms my ( $or_self, @a_vals ) = @_;
514
515465029.0ms9300650ms return $or_self->execute_query( "
# spent 642ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 138µs/call # spent 8.28ms making 4650 calls to DBI::common::STORE, avg 2µs/call
516 SELECT bench_id, bench_additional_type_id, created_at
517 FROM $or_self->{config}{tables}{additional_type_relation_table}
518 WHERE bench_id = ? AND bench_additional_type_id = ?
519 ", @a_vals );
520
521}
522
523sub insert_raw_bench_bundle {
524
525 my ( $or_self, @a_vals ) = @_;
526
527 return $or_self->execute_query( "
528 INSERT INTO raw_bench_bundles
529 (raw_bench_bundle_serialized)
530 VALUES ( ? )
531 ", @a_vals );
532
533}
534
535sub copy_benchmark_backup_value {
536
537 my ( $or_self, $hr_vals ) = @_;
538
539 for my $s_param (qw/ new_bench_value_id old_bench_value_id /) {
540 if (! $hr_vals->{$s_param} ) {
541 require Carp;
542 Carp::confess("missing parameter '$s_param'");
543 return;
544 }
545 }
546
547 return $or_self->execute_query( "
548 INSERT INTO $or_self->{config}{tables}{benchmark_backup_value_table}
549 ( bench_value_id, bench_id, bench_subsume_type_id, bench_value, active, created_at )
550 SELECT
551 ?, bench_id, bench_subsume_type_id, bench_value, active, created_at
552 FROM
553 $or_self->{config}{tables}{benchmark_value_table}
554 WHERE
555 bench_value_id = ?
556 ", @{$hr_vals}{qw/ new_bench_value_id old_bench_value_id /} );
557
558}
559
560sub copy_benchmark_backup_additional_relations {
561
562 my ( $or_self, $hr_vals ) = @_;
563
564 for my $s_param (qw/ new_bench_value_id old_bench_value_id /) {
565 if (! $hr_vals->{$s_param} ) {
566 require Carp;
567 Carp::confess("missing parameter '$s_param'");
568 return;
569 }
570 }
571
572 return $or_self->execute_query( "
573 INSERT INTO $or_self->{config}{tables}{backup_additional_relation_table}
574 ( bench_backup_value_id, bench_additional_value_id, active, created_at )
575 SELECT
576 ?, bench_additional_value_id, active, created_at
577 FROM
578 $or_self->{config}{tables}{additional_relation_table}
579 WHERE
580 bench_value_id = ?
581 ", @{$hr_vals}{qw/ new_bench_value_id old_bench_value_id /} );
582
583}
584
585sub update_benchmark_backup_value {
586
587 my ( $or_self, $hr_vals ) = @_;
588
589 return $or_self->execute_query( "
590 UPDATE $or_self->{config}{tables}{benchmark_backup_value_table}
591 SET bench_value_id = ?
592 WHERE bench_value_id = ?
593 ", @{$hr_vals}{qw/
594 new_bench_value_id
595 old_bench_value_id
596 /} );
597
598}
599
600
# spent 335ms (5.55+329) within BenchmarkAnything::Storage::Backend::SQL::Query::common::start_processing_raw_bench_bundle which was called 1000 times, avg 335µs/call: # 1000 times (5.55ms+329ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 425 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 335µs/call
sub start_processing_raw_bench_bundle {
601
6021000957µs my ( $or_self, @a_vals ) = @_;
603
60410003.94ms2000331ms return $or_self->execute_query( "
# spent 329ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 329µs/call # spent 2.08ms making 1000 calls to DBI::common::STORE, avg 2µs/call
605 UPDATE raw_bench_bundles
606 SET processing = 1
607 WHERE raw_bench_bundle_id = ?
608 ", @a_vals );
609
610}
611
612
# spent 673ms (8.21+665) within BenchmarkAnything::Storage::Backend::SQL::Query::common::update_raw_bench_bundle_set_processed which was called 1000 times, avg 673µs/call: # 1000 times (8.21ms+665ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 441 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 673µs/call
sub update_raw_bench_bundle_set_processed {
613
61410001.09ms my ( $or_self, @a_vals ) = @_;
615
616100028.0ms2000669ms return $or_self->execute_query( "
# spent 665ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 665µs/call # spent 3.69ms making 1000 calls to DBI::common::STORE, avg 4µs/call
617 UPDATE raw_bench_bundles
618 SET processed=1,
619 processing=0
620 WHERE raw_bench_bundle_id = ?
621 ", @a_vals );
622
623}
624
625sub delete_benchmark_additional_relations {
626
627 my ( $or_self, @a_vals ) = @_;
628
629 return $or_self->execute_query( "
630 DELETE FROM $or_self->{config}{tables}{additional_relation_table}
631 WHERE bench_value_id = ?
632 ", @a_vals );
633
634}
635
636sub delete_benchmark_value {
637
638 my ( $or_self, @a_vals ) = @_;
639
640 return $or_self->execute_query( "
641 DELETE FROM $or_self->{config}{tables}{benchmark_value_table}
642 WHERE bench_value_id = ?
643 ", @a_vals );
644
645}
646
647# Garbage Collection
648
# spent 23.5ms (12µs+23.5) within BenchmarkAnything::Storage::Backend::SQL::Query::common::delete_processed_raw_bench_bundles which was called: # once (12µs+23.5ms) by BenchmarkAnything::Storage::Backend::SQL::gc at line 455 of BenchmarkAnything/Storage/Backend/SQL.pm
sub delete_processed_raw_bench_bundles {
649
6501500ns my ( $or_self, @a_vals ) = @_;
651
652111µs223.5ms return $or_self->execute_query( "
# spent 23.5ms making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query # spent 9µs making 1 call to DBI::common::STORE
653 DELETE FROM raw_bench_bundles
654 WHERE processed=1 AND
655 processing=0
656 ", @a_vals );
657
658}
659
660sub copy_additional_values {
661
662 my ( $or_self, $hr_vals ) = @_;
663
664 for my $s_param (qw/ new_bench_value_id old_bench_value_id /) {
665 if (! $hr_vals->{$s_param} ) {
666 require Carp;
667 Carp::confess("missing parameter '$s_param'");
668 return;
669 }
670 }
671
672 return $or_self->execute_query( "
673 INSERT INTO $or_self->{config}{tables}{additional_relation_table}
674 ( bench_value_id, bench_additional_value_id, active, created_at )
675 SELECT
676 ?, bench_additional_value_id, 1, @{[$or_self->_NOW]}
677 FROM
678 $or_self->{config}{tables}{additional_relation_table}
679 WHERE
680 bench_value_id = ?
681 ", @{$hr_vals}{qw/ new_bench_value_id old_bench_value_id /} );
682
683}
684
685
# spent 406ms (20.8+385) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_lock which was called 1000 times, avg 406µs/call: # 1000 times (20.8ms+385ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 417 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 406µs/call
sub select_raw_bench_bundle_for_lock {
686
68710001.06ms my ( $or_self, @a_vals ) = @_;
688
689100011.1ms3000387ms return $or_self->execute_query( "
# spent 383ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 383µs/call # spent 2.42ms making 1000 calls to DBI::common::STORE, avg 2µs/call # spent 2.21ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_FOR_UPDATE, avg 2µs/call
690 SELECT raw_bench_bundle_id
691 FROM raw_bench_bundles
692 WHERE processed=0 AND
693 processing=0
694 ORDER BY raw_bench_bundle_id ASC
695 LIMIT 1
696 @{[$or_self->_FOR_UPDATE]}
697 ", @a_vals );
698}
699
700
# spent 251ms (26.2+224) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_processing which was called 1000 times, avg 251µs/call: # 1000 times (26.2ms+224ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 435 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 251µs/call
sub select_raw_bench_bundle_for_processing {
701
70210001.41ms my ( $or_self, @a_vals ) = @_;
703
704100010.8ms3000227ms return $or_self->execute_query( "
# spent 222ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 222µs/call # spent 2.20ms making 1000 calls to DBI::common::STORE, avg 2µs/call # spent 2.07ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_FOR_UPDATE, avg 2µs/call
705 SELECT raw_bench_bundle_serialized
706 FROM raw_bench_bundles
707 WHERE raw_bench_bundle_id = ?
708 LIMIT 1
709 @{[$or_self->_FOR_UPDATE]}
710 ", @a_vals );
711}
712
71314µs1;
714
715__END__