| 1 | package Tapper::Benchmark; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # git description: v0.012-2-g03356da | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Autonomous SQL backend to store benchmarks | ||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | $Tapper::Benchmark::VERSION = '5.0.0'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | my $hr_default_config = { | |||||||||||||||||||||||||||||||||||||||||
| 11 | select_cache => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | default_aggregation => 'min', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | tables => { | ||||||||||||||||||||||||||||||||||||||||||
| 14 | unit_table => 'bench_units', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | benchmark_table => 'benchs', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | benchmark_value_table => 'bench_values', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | subsume_type_table => 'bench_subsume_types', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | benchmark_backup_value_table => 'bench_backup_values', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | additional_type_table => 'bench_additional_types', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | additional_value_table => 'bench_additional_values', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | additional_relation_table => 'bench_additional_relations', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | additional_type_relation_table => 'bench_additional_type_relations', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | backup_additional_relation_table => 'bench_backup_additional_relations', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $fn_add_subsumed_point = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my ( $or_self, $hr_atts ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $or_self->{query}->start_transaction(); | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # insert subsumed benchmark value | ||||||||||||||||||||||||||||||||||||||||||
| 36 | $or_self->{query}->insert_benchmark_value( | ||||||||||||||||||||||||||||||||||||||||||
| 37 | $hr_atts->{rows}[0]{bench_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | $hr_atts->{type_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | $hr_atts->{VALUE}, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | my $i_bench_value_id = $or_self->{query}->last_insert_id( | ||||||||||||||||||||||||||||||||||||||||||
| 42 | $or_self->{config}{tables}{benchmark_value_table}, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | 'bench_value_id', | |||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # insert subsumed benchmark additional values | ||||||||||||||||||||||||||||||||||||||||||
| 47 | $or_self->{query}->copy_additional_values({ | ||||||||||||||||||||||||||||||||||||||||||
| 48 | new_bench_value_id => $i_bench_value_id, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | old_bench_value_id => $hr_atts->{rows}[0]{bench_value_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | for my $hr_backup_row ( @{$hr_atts->{rows}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ( $hr_backup_row->{bench_subsume_type_rank} == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ( $hr_atts->{backup} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | # copy data rows to backup table | ||||||||||||||||||||||||||||||||||||||||||
| 57 | $or_self->{query}->copy_benchmark_backup_value({ | ||||||||||||||||||||||||||||||||||||||||||
| 58 | new_bench_value_id => $i_bench_value_id, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | old_bench_value_id => $hr_backup_row->{bench_value_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 61 | my $i_bench_backup_value_id = $or_self->{query}->last_insert_id( | ||||||||||||||||||||||||||||||||||||||||||
| 62 | $or_self->{config}{tables}{benchmark_backup_value_table}, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | 'bench_backup_value_id', | |||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | $or_self->{query}->copy_benchmark_backup_additional_relations({ | ||||||||||||||||||||||||||||||||||||||||||
| 66 | new_bench_value_id => $i_bench_backup_value_id, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | old_bench_value_id => $hr_backup_row->{bench_value_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | # update bench_value_id in backup table | ||||||||||||||||||||||||||||||||||||||||||
| 73 | $or_self->{query}->update_benchmark_backup_value({ | ||||||||||||||||||||||||||||||||||||||||||
| 74 | new_bench_value_id => $i_bench_value_id, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | old_bench_value_id => $hr_backup_row->{bench_value_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # now lets remove the old rows | ||||||||||||||||||||||||||||||||||||||||||
| 80 | $or_self->{query}->delete_benchmark_additional_relations( | ||||||||||||||||||||||||||||||||||||||||||
| 81 | $hr_backup_row->{bench_value_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 83 | $or_self->{query}->delete_benchmark_value( | ||||||||||||||||||||||||||||||||||||||||||
| 84 | $hr_backup_row->{bench_value_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $or_self->{query}->finish_transaction( $@ ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my ( $s_self, $hr_atts ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $or_self = bless {}, $s_self; | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | for my $s_key (qw/ dbh /) { | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (! $hr_atts->{$s_key} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | Carp::confess("missing '$s_key' parameter"); | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | # get tapper benchmark configuration | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $or_self->{config} = { %{$hr_default_config} }; | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( $hr_atts->{config} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | require Hash::Merge; | |||||||||||||||||||||||||||||||||||||||||
| 116 | $or_self->{config} = { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | Hash::Merge | ||||||||||||||||||||||||||||||||||||||||||
| 118 | ->new('LEFT_PRECEDENT') | ||||||||||||||||||||||||||||||||||||||||||
| 119 | ->merge( | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | %{$hr_atts->{config}}, | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | %{$or_self->{config}}, | |||||||||||||||||||||||||||||||||||||||||
| 122 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 123 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | require CHI; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( $or_self->{config}{select_cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $or_self->{cache} = CHI->new( driver => 'RawMemory', global => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $s_module = "Tapper::Benchmark::Query::$hr_atts->{dbh}{Driver}{Name}"; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $fn_new_sub; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | require Module::Load; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | Module::Load::load( $s_module ); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $fn_new_sub = $s_module->can('new'); | |||||||||||||||||||||||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ( $@ || !$fn_new_sub ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $fn_new_sub
MC/DC0%0/2
$@ or not $fn_new_sub
$@
not $fn_new_sub
Truth table0%0/3
A or not(B)
A= $@B= not $fn_new_sub
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | Carp::confess("database engine '$hr_atts->{dbh}{Driver}{Name}' not supported"); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | $or_self->{query} = $s_module->new({ | ||||||||||||||||||||||||||||||||||||||||||
| 147 | dbh => $hr_atts->{dbh}, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | driver => $hr_atts->{dbh}{Driver}{Name}, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | debug => $hr_atts->{debug} || 0, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | config => $or_self->{config}, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hr_atts->{'debug'} || 0
MC/DC0%0/1
$hr_atts->{'debug'} || 0
$hr_atts->{'debug'}
Truth table0%0/2
A
A= $hr_atts->{'debug'}
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return $or_self; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub add_single_benchmark { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_single_benchmark: not called CC=27 SCAR=66.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my ( $or_self, $hr_benchmark, $hr_options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $hr_config = $or_self->{config}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | # benchmark | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $i_benchmark_id; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ( $hr_benchmark->{NAME} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | my $hr_bench_select = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ->select_benchmark( $hr_benchmark->{NAME} ) | ||||||||||||||||||||||||||||||||||||||||||
| 170 | ->fetchrow_hashref() | ||||||||||||||||||||||||||||||||||||||||||
| 171 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $i_benchmark_id = $hr_bench_select->{bench_id}; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $i_unit_id; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ( $hr_benchmark->{UNIT} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | my $hr_unit_select = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 179 | ->select_unit( $hr_benchmark->{UNIT} ) | ||||||||||||||||||||||||||||||||||||||||||
| 180 | ->fetchrow_hashref() | ||||||||||||||||||||||||||||||||||||||||||
| 181 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $i_unit_id = $hr_unit_select->{bench_unit_id}; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | $or_self->{query}->insert_unit( | ||||||||||||||||||||||||||||||||||||||||||
| 186 | $hr_benchmark->{UNIT}, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 188 | $i_unit_id = $or_self->{query}->last_insert_id( | ||||||||||||||||||||||||||||||||||||||||||
| 189 | $hr_config->{tables}{unit_table}, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | 'bench_unit_id', | |||||||||||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | $or_self->{query}->insert_benchmark( | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $hr_benchmark->{NAME}, $i_unit_id, | |||||||||||||||||||||||||||||||||||||||||
| 196 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 197 | $i_benchmark_id = $or_self->{query}->last_insert_id( | ||||||||||||||||||||||||||||||||||||||||||
| 198 | $hr_config->{tables}{benchmark_table}, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | 'bench_id', | |||||||||||||||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | Carp::confess('missing element "NAME"'); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$hr_benchmark->{"data"} and ref $hr_benchmark->{"data"} eq "ARRAY" and @{$hr_benchmark->{"data"};}
$hr_benchmark->{"data"} and ref $hr_benchmark->{"data"} eq "ARRAY"
MC/DC0%0/3
$hr_benchmark->{"data"} and ref $hr_benchmark->{"data"} eq "ARRAY" and @{$hr_benchmark->{"data"};}
$hr_benchmark->{"data"}
ref $hr_benchmark->{"data"} eq "ARRAY"
@{$hr_benchmark->{"data"};}
Truth table0%0/4
A and B and C
A= $hr_benchmark->{"data"}B= ref $hr_benchmark->{"data"} eq "ARRAY"C= @{$hr_benchmark->{"data"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | $hr_benchmark->{data} | ||||||||||||||||||||||||||||||||||||||||||
| 211 | && ref( $hr_benchmark->{data} ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | && @{$hr_benchmark->{data}} | |||||||||||||||||||||||||||||||||||||||||
| 213 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | my $i_benchmark_subsume_type_id = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 216 | ->select_min_subsume_type() | ||||||||||||||||||||||||||||||||||||||||||
| 217 | ->fetchrow_hashref() | ||||||||||||||||||||||||||||||||||||||||||
| 218 | ->{bench_subsume_type_id} | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ; | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $i_counter = 1; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | for my $hr_point ( @{$hr_benchmark->{data}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ( not exists $hr_point->{VALUE} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if ( $hr_options->{force} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | Carp::cluck("missing parameter 'VALUE' in element $i_counter"); | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | Carp::confess("missing parameter 'VALUE' in element $i_counter"); | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | # benchmark value | ||||||||||||||||||||||||||||||||||||||||||
| 235 | $or_self->{query}->insert_benchmark_value( | ||||||||||||||||||||||||||||||||||||||||||
| 236 | $i_benchmark_id, $i_benchmark_subsume_type_id, $hr_point->{VALUE}, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 238 | my $i_benchmark_value_id = $or_self->{query}->last_insert_id( | ||||||||||||||||||||||||||||||||||||||||||
| 239 | $hr_config->{tables}{benchmark_value_table}, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | 'bench_value_id', | |||||||||||||||||||||||||||||||||||||||||
| 241 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ADDITIONAL: for my $s_key ( keys %{$hr_point} ) { | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | next ADDITIONAL if $s_key eq 'VALUE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | next ADDITIONAL if not defined $hr_point->{$s_key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | # additional type | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $i_addtype_id; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $i_addtype_id = $or_self->{cache}->get("addtype||$s_key"); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ( !$i_addtype_id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | my $hr_addtype_select = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 256 | ->select_addtype( $s_key ) | ||||||||||||||||||||||||||||||||||||||||||
| 257 | ->fetchrow_hashref() | ||||||||||||||||||||||||||||||||||||||||||
| 258 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $i_addtype_id = $hr_addtype_select->{bench_additional_type_id}; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | $or_self->{query}->insert_addtype( | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $s_key, | |||||||||||||||||||||||||||||||||||||||||
| 264 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 265 | $i_addtype_id = $or_self->{query}->last_insert_id( | ||||||||||||||||||||||||||||||||||||||||||
| 266 | $hr_config->{tables}{addition_type_table}, | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | 'bench_additional_type_id', | |||||||||||||||||||||||||||||||||||||||||
| 268 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $or_self->{cache}->set( "addtype||$s_key" => $i_addtype_id ); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | # benchmark - additional type - relation | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $b_inserted = 0; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $s_addtyperel = "$i_benchmark_id|$i_addtype_id"; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ( $or_self->{cache}->get("addtyperel||$s_addtyperel") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $b_inserted = 1; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if (! $b_inserted ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if(! | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 286 | ->select_addtyperelation( $i_benchmark_id, $i_addtype_id ) | ||||||||||||||||||||||||||||||||||||||||||
| 287 | ->fetchrow_hashref() | ||||||||||||||||||||||||||||||||||||||||||
| 288 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ->insert_addtyperelation( $i_benchmark_id, $i_addtype_id ) | |||||||||||||||||||||||||||||||||||||||||
| 291 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $or_self->{cache}->set("addtyperel||$s_addtyperel" => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | # additional value | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $i_addvalue_id; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $s_addvalue_key = "$i_addtype_id|$hr_point->{$s_key}"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $i_addvalue_id = $or_self->{cache}->get("addvalue||$s_addvalue_key"); | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if (! $i_addvalue_id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | my $hr_addvalue_select = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 307 | ->select_addvalue( $i_addtype_id, $hr_point->{$s_key} ) | ||||||||||||||||||||||||||||||||||||||||||
| 308 | ->fetchrow_hashref() | ||||||||||||||||||||||||||||||||||||||||||
| 309 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $i_addvalue_id = $hr_addvalue_select->{bench_additional_value_id}; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | $or_self->{query}->insert_addvalue( | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $i_addtype_id, $hr_point->{$s_key}, | |||||||||||||||||||||||||||||||||||||||||
| 315 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 316 | $i_addvalue_id = $or_self->{query}->last_insert_id( | ||||||||||||||||||||||||||||||||||||||||||
| 317 | $hr_config->{tables}{addition_type_table}, | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | 'bench_additional_value_id', | |||||||||||||||||||||||||||||||||||||||||
| 319 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $or_self->{cache}->set( "addvalue||$s_addvalue_key" => $i_addvalue_id ); | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | # additional value relation | ||||||||||||||||||||||||||||||||||||||||||
| 327 | $or_self->{query}->insert_addvaluerelation( | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $i_benchmark_value_id, $i_addvalue_id, | |||||||||||||||||||||||||||||||||||||||||
| 329 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | } # ADDITIONAL | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $i_counter++; | |||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | Carp::cluck('no benchmark data found'); | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub enqueue_multi_benchmark { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enqueue_multi_benchmark: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my ( $or_self, $ar_data_points, $hr_options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | require Sereal::Encoder; | |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $s_serialized = Sereal::Encoder->new->encode($ar_data_points); | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $or_self->{query}->insert_raw_bench_bundle($s_serialized); | |||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | # dequeues a single bundle (can contain multiple data points) | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub process_queued_multi_benchmark { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_queued_multi_benchmark: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my ( $or_self, $hr_options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $i_id; | |||||||||||||||||||||||||||||||||||||||||
| 366 | my $s_serialized; | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $ar_data_points; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $ar_results; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $or_result; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $driver = $or_self->{query}{dbh}{Driver}{Name}; | |||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | # ===== exclusively pick single raw entry ===== | ||||||||||||||||||||||||||||||||||||||||||
| 373 | # Lock single row via processing=1 so that only one worker handles it! | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | $or_self->{query}{dbh}->do("set transaction isolation level read committed") if $driver eq "mysql"; # avoid deadlocks due to gap locking | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $or_self->{query}->start_transaction; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $ar_results = $or_self->{query}->select_raw_bench_bundle_for_lock; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $or_result = $ar_results->fetchrow_hashref; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $i_id = $or_result->{raw_bench_bundle_id}; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if (!$i_id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $or_self->{query}->finish_transaction( $@ ); | |||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | $or_self->{query}{dbh}->do("set transaction isolation level repeatable read") if $driver eq "mysql"; # reset to normal gap locking | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | goto RETURN ; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $or_self->{query}->start_processing_raw_bench_bundle($i_id); | |||||||||||||||||||||||||||||||||||||||||
| 386 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $or_self->{query}->finish_transaction( $@ ); | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $or_self->{query}{dbh}->do("set transaction isolation level repeatable read") if $driver eq "mysql"; # reset to normal gap locking | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | # ===== process that single raw entry ===== | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $or_self->{query}->start_transaction; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | require Sereal::Decoder; | |||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $ar_results = $or_self->{query}->select_raw_bench_bundle_for_processing($i_id); | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $s_serialized = $ar_results->fetchrow_hashref->{raw_bench_bundle_serialized}; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $ar_data_points = Sereal::Decoder::decode_sereal($s_serialized); | |||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | # preserve order, otherwise add_multi_benchmark() would reorder to optimize insert | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $or_self->add_multi_benchmark([$_], $hr_options) foreach @$ar_data_points; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $or_self->{query}->update_raw_bench_bundle_set_processed($i_id); | |||||||||||||||||||||||||||||||||||||||||
| 402 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $or_self->{query}->finish_transaction( $@ ); | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | RETURN: | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | return $@ ? undef : $i_id; | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | # garbage collect - initially raw_bench_bundles, but also other stuff. | ||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | sub gc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my ( $or_self, $hr_options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $or_self->{query}->delete_processed_raw_bench_bundles; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub add_multi_benchmark { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_multi_benchmark: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my ( $or_self, $ar_data_points, $hr_options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $i_counter = 1; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my %h_benchmarks = (); | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | for my $hr_data_point ( @{$ar_data_points} ) { | |||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | for my $s_param (qw/ NAME VALUE /) { | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | if ( not exists $hr_data_point->{$s_param} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if ( $hr_options->{force} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | Carp::cluck("missing parameter '$s_param' in element $i_counter"); | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | Carp::confess("missing parameter '$s_param' in element $i_counter"); | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my ( $s_name, $s_unit ) = delete @{$hr_data_point}{qw/ NAME UNIT /}; | |||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | if (! $h_benchmarks{$s_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $h_benchmarks{$s_name} = { | |||||||||||||||||||||||||||||||||||||||||
| 442 | NAME => $s_name, | ||||||||||||||||||||||||||||||||||||||||||
| 443 | UNIT => $s_unit, | ||||||||||||||||||||||||||||||||||||||||||
| 444 | data => [], | ||||||||||||||||||||||||||||||||||||||||||
| 445 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | $h_benchmarks{$s_name}{UNIT} ||= $s_unit; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$h_benchmarks{$s_name}{"UNIT"} ||= $s_unit
MC/DC0%0/2
$h_benchmarks{$s_name}{"UNIT"} ||= $s_unit
$h_benchmarks{$s_name}{"UNIT"}
$s_unit
Truth table0%0/3
A ||= B
A= $h_benchmarks{$s_name}{"UNIT"}B= $s_unit
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | push @{$h_benchmarks{$s_name}{data}}, $hr_data_point; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $i_counter++; | |||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | for my $hr_benchmark ( values %h_benchmarks ) { | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $or_self->add_single_benchmark( $hr_benchmark, $hr_options ); | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my ( $or_self, $hr_search ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | return $or_self->{query}->select_benchmark_values( | ||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $hr_search | |||||||||||||||||||||||||||||||||||||||||
| 470 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | sub list_benchmark_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_benchmark_names: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my ( $or_self, $s_pattern ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | my $ar_pattern = defined($s_pattern) ? [$s_pattern] : []; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $s_key; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | require JSON::XS; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $s_key = JSON::XS::encode_json($ar_pattern); | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if ( my $ar_search_data = $or_self->{cache}->get("list_benchmark_names||$s_key") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return $ar_search_data; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | my $ar_result = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ->select_benchmark_names( @$ar_pattern ) | |||||||||||||||||||||||||||||||||||||||||
| 491 | ->fetchall_arrayref([0]); | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $ar_benchmark_names = [ map { $_->[0] } @$ar_result ]; | |||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $or_self->{cache}->set( "list_benchmark_names||$s_key" => $ar_benchmark_names ); | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | return $ar_benchmark_names; | |||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | sub get_single_benchmark_point { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_single_benchmark_point: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ( $or_self, $i_bench_value_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | return {} unless $i_bench_value_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | # cache? | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my $s_key; | |||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | require JSON::XS; | |||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $s_key = JSON::XS::encode_json({bench_value_id => $i_bench_value_id}); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | if ( my $hr_search_data = $or_self->{cache}->get("get_single_benchmark_point||$s_key") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | return $hr_search_data; | |||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | # fetch all additional key/value fields | ||||||||||||||||||||||||||||||||||||||||||
| 519 | my $ar_query_result = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ->select_complete_benchmark_point( $i_bench_value_id ) | |||||||||||||||||||||||||||||||||||||||||
| 521 | ->fetchall_arrayref({}); | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | # fetch essentials, like NAME, VALUE, UNIT | ||||||||||||||||||||||||||||||||||||||||||
| 524 | my $hr_essentials = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ->select_benchmark_point_essentials( $i_bench_value_id ) | |||||||||||||||||||||||||||||||||||||||||
| 526 | ->fetchrow_hashref(); | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | # create complete BenchmarkAnything-like key/value entry | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $hr_result; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | $hr_result = { map { ($_->{bench_additional_type} => $_->{bench_additional_value} ) } @$ar_query_result }; | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $hr_result->{NAME} = $hr_essentials->{bench}; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $hr_result->{VALUE} = $hr_essentials->{bench_value}; | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | $hr_result->{UNIT} = $hr_essentials->{bench_unit} if $hr_essentials->{bench_unit}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | # cache! | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $or_self->{cache}->set( "get_single_benchmark_point||$s_key" => $hr_result ); | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | return $hr_result; | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | sub search_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_array: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my ( $or_self, $hr_search ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $s_key; | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | require JSON::XS; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $s_key = JSON::XS::encode_json($hr_search); | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | if ( my $ar_search_data = $or_self->{cache}->get("search_array||$s_key") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | return $ar_search_data; | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my $ar_result = $or_self | |||||||||||||||||||||||||||||||||||||||||
| 557 | ->search( $hr_search ) | ||||||||||||||||||||||||||||||||||||||||||
| 558 | ->fetchall_arrayref({}) | ||||||||||||||||||||||||||||||||||||||||||
| 559 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $or_self->{cache}->set( "search_array||$s_key" => $ar_result ); | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return $ar_result; | |||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | sub search_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_hash: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my ( $or_self, $hr_search ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my $s_key; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | require JSON::XS; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $s_key = JSON::XS::encode_json($hr_search); | |||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ( my $hr_search_data = $or_self->{cache}->get( "search_hash||$s_key" ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return $hr_search_data; | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | if (! $hr_search->{keys} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | Carp::confess(q#cannot get hash search result without 'keys'#); | |||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | my $hr_result = $or_self | ||||||||||||||||||||||||||||||||||||||||||
| 589 | ->search( $hr_search ) | ||||||||||||||||||||||||||||||||||||||||||
| 590 | ->fetchall_hashref($hr_search->{keys}) | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ; | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | if ( $or_self->{cache} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $or_self->{cache}->set( "search_hash||$s_key" => $hr_result ) | |||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return $hr_result; | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | sub subsume { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subsume: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my ( $or_self, $hr_options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | for my $s_parameter (qw/ subsume_type /) { | |||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | if (! $hr_options->{$s_parameter}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | Carp::confess("missing parameter '$s_parameter'"); | |||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | # check if subsume type exists | ||||||||||||||||||||||||||||||||||||||||||
| 614 | my $hr_subsume_type = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 615 | ->select_subsume_type( $hr_options->{subsume_type} ) | ||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ->fetchrow_hashref() | |||||||||||||||||||||||||||||||||||||||||
| 617 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | if (! $hr_subsume_type ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | Carp::confess("subsume type '$hr_options->{subsume_type}' not exists"); | |||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | if ( $hr_subsume_type->{bench_subsume_type_rank} == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | Carp::confess("cannot subsume with type '$hr_options->{subsume_type}'"); | |||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | # looking for values with with a higher rank subsume type | ||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 632 | ->select_check_subsumed_values({ | ||||||||||||||||||||||||||||||||||||||||||
| 633 | date_to => $hr_options->{date_to}, | ||||||||||||||||||||||||||||||||||||||||||
| 634 | date_from => $hr_options->{date_from}, | ||||||||||||||||||||||||||||||||||||||||||
| 635 | subsume_type_id => $hr_subsume_type->{bench_subsume_type_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 636 | }) | ||||||||||||||||||||||||||||||||||||||||||
| 637 | ->rows() | ||||||||||||||||||||||||||||||||||||||||||
| 638 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | Carp::confess( | |||||||||||||||||||||||||||||||||||||||||
| 641 | "cannot use subsume type '$hr_options->{subsume_type}' " . | ||||||||||||||||||||||||||||||||||||||||||
| 642 | 'because a higher rank subsume type is already used for this date period' | ||||||||||||||||||||||||||||||||||||||||||
| 643 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | # look if excluded additional types really exists | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my @a_excluded_adds; | |||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | if ( $hr_options->{exclude_additionals} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | for my $s_additional_type ( @{$hr_options->{exclude_additionals}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | my $hr_addtype = $or_self->{query} | ||||||||||||||||||||||||||||||||||||||||||
| 653 | ->select_addtype( $s_additional_type ) | ||||||||||||||||||||||||||||||||||||||||||
| 654 | ->fetchrow_hashref() | ||||||||||||||||||||||||||||||||||||||||||
| 655 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 656 | push @a_excluded_adds, $hr_addtype->{bench_additional_type_id} | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 658 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | Carp::confess( "additional type '$s_additional_type' not exists" ); | |||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | # get all data points for subsume | ||||||||||||||||||||||||||||||||||||||||||
| 667 | my $or_data_values = $or_self->{query}->select_data_values_for_subsume({ | ||||||||||||||||||||||||||||||||||||||||||
| 668 | date_to => $hr_options->{date_to}, | ||||||||||||||||||||||||||||||||||||||||||
| 669 | date_from => $hr_options->{date_from}, | ||||||||||||||||||||||||||||||||||||||||||
| 670 | exclude_additionals => \@a_excluded_adds, | ||||||||||||||||||||||||||||||||||||||||||
| 671 | subsume_type_id => $hr_subsume_type->{bench_subsume_type_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | require DateTime::Format::Strptime; | |||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my $or_strp = DateTime::Format::Strptime->new( pattern => '%F %T', ); | |||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my @a_rows; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | my $i_counter = 0; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $i_sum_value = 0; | |||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | my $b_backup = ((not exists $hr_options->{backup}) || $hr_options->{backup}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $hr_options->{"backup"} or $hr_options->{"backup"}
MC/DC0%0/2
not exists $hr_options->{"backup"} or $hr_options->{"backup"}
not exists $hr_options->{"backup"}
$hr_options->{"backup"}
Truth table0%0/3
not(A) or B
A= not exists $hr_options->{"backup"}B= $hr_options->{"backup"}
| |||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | my $s_last_key = q##; | |||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | while ( my $hr_values = $or_data_values->fetchrow_hashref() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | my $s_act_key = join '__', | ||||||||||||||||||||||||||||||||||||||||||
| 686 | $hr_values->{bench_id}, | ||||||||||||||||||||||||||||||||||||||||||
| 687 | $or_strp->parse_datetime( $hr_values->{created_at} )->strftime( $hr_subsume_type->{datetime_strftime_pattern} ), | ||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | $hr_values->{additionals} || q##, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hr_values->{'additionals'} || ''
MC/DC0%0/1
$hr_values->{'additionals'} || ''
$hr_values->{'additionals'}
Truth table0%0/2
A
A= $hr_values->{'additionals'}
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | if ( $s_last_key ne $s_act_key ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ( $i_counter ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | $or_self->$fn_add_subsumed_point({ | ||||||||||||||||||||||||||||||||||||||||||
| 695 | rows => \@a_rows, | ||||||||||||||||||||||||||||||||||||||||||
| 696 | VALUE => $i_sum_value / $i_counter, | ||||||||||||||||||||||||||||||||||||||||||
| 697 | backup => $b_backup, | ||||||||||||||||||||||||||||||||||||||||||
| 698 | type_id => $hr_subsume_type->{bench_subsume_type_id} | ||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | @a_rows = (); | |||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | $i_counter = 0; | |||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | $i_sum_value = 0; | |||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | $s_last_key = $s_act_key; | |||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | $i_counter += 1; | |||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $i_sum_value += $hr_values->{bench_value}; | |||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | push @a_rows, $hr_values; | |||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | if ( $i_counter ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | $or_self->$fn_add_subsumed_point({ | ||||||||||||||||||||||||||||||||||||||||||
| 718 | rows => \@a_rows, | ||||||||||||||||||||||||||||||||||||||||||
| 719 | VALUE => $i_sum_value / $i_counter, | ||||||||||||||||||||||||||||||||||||||||||
| 720 | backup => $b_backup, | ||||||||||||||||||||||||||||||||||||||||||
| 721 | type_id => $hr_subsume_type->{bench_subsume_type_id} | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | __END__ | ||||||||||||||||||||||||||||||||||||||||||