mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 01:16:14 +00:00
EventAggregator: Remove apdex code
This commit is contained in:
@@ -619,16 +619,6 @@ sub calculate_statistical_metrics {
|
||||
$classes->{$class}->{$attrib}->{all},
|
||||
$classes->{$class}->{$attrib}
|
||||
);
|
||||
|
||||
# Apdex (http://code.google.com/p/maatkit/issues/detail?id=1054)
|
||||
if ( $args{apdex_t} && $attrib eq 'Query_time' ) {
|
||||
$class_metrics->{$class}->{$attrib}->{apdex_t} = $args{apdex_t};
|
||||
$class_metrics->{$class}->{$attrib}->{apdex}
|
||||
= $self->calculate_apdex(
|
||||
t => $args{apdex_t},
|
||||
samples => $classes->{$class}->{$attrib}->{all},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -784,9 +774,6 @@ sub metrics {
|
||||
median => $metrics->{classes}->{$where}->{$attrib}->{median} || 0,
|
||||
pct_95 => $metrics->{classes}->{$where}->{$attrib}->{pct_95} || 0,
|
||||
stddev => $metrics->{classes}->{$where}->{$attrib}->{stddev} || 0,
|
||||
|
||||
apdex_t => $metrics->{classes}->{$where}->{$attrib}->{apdex_t},
|
||||
apdex => $metrics->{classes}->{$where}->{$attrib}->{apdex},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1164,70 +1151,6 @@ sub _deep_copy_attrib_vals {
|
||||
return $copy;
|
||||
}
|
||||
|
||||
# Sub: calculate_apdex
|
||||
# Calculate the Apdex score for the given T and response times.
|
||||
# <http://www.apdex.org/documents/ApdexTechnicalSpecificationV11_000.pdf>
|
||||
#
|
||||
# Parameters:
|
||||
# %args - Arguments
|
||||
#
|
||||
# Required Arguments:
|
||||
# t - Target threshold
|
||||
# samples - Hashref with bucketized response time values,
|
||||
# i.e. { bucket_number => n_responses, }
|
||||
#
|
||||
# Returns:
|
||||
# Apdex score
|
||||
sub calculate_apdex {
|
||||
my ( $self, %args ) = @_;
|
||||
my @required_args = qw(t samples);
|
||||
foreach my $arg ( @required_args ) {
|
||||
die "I need a $arg argument" unless $args{$arg};
|
||||
}
|
||||
my ($t, $samples) = @args{@required_args};
|
||||
|
||||
if ( $t <= 0 ) {
|
||||
die "Invalid target threshold (T): $t. T must be greater than zero";
|
||||
}
|
||||
|
||||
my $f = 4 * $t;
|
||||
PTDEBUG && _d("Apdex T =", $t, "F =", $f);
|
||||
|
||||
my $satisfied = 0;
|
||||
my $tolerating = 0;
|
||||
my $frustrated = 0; # just for debug output
|
||||
my $n_samples = 0;
|
||||
BUCKET:
|
||||
for my $bucket ( keys %$samples ) {
|
||||
my $n_responses = $samples->{$bucket};
|
||||
my $response_time = $buck_vals[$bucket];
|
||||
|
||||
# Response time increases from 0 to F.
|
||||
# 0 --- T --- F
|
||||
# ^ ^-- tolerating zone
|
||||
# |
|
||||
# +-------- satisfied zone
|
||||
if ( $response_time <= $t ) {
|
||||
$satisfied += $n_responses;
|
||||
}
|
||||
elsif ( $response_time <= $f ) {
|
||||
$tolerating += $n_responses;
|
||||
}
|
||||
else {
|
||||
$frustrated += $n_responses;
|
||||
}
|
||||
|
||||
$n_samples += $n_responses;
|
||||
}
|
||||
|
||||
my $apdex = sprintf('%.2f', ($satisfied + ($tolerating / 2)) / $n_samples);
|
||||
PTDEBUG && _d($n_samples, "samples,", $satisfied, "satisfied,",
|
||||
$tolerating, "tolerating,", $frustrated, "frustrated, Apdex score:",
|
||||
$apdex);
|
||||
|
||||
return $apdex;
|
||||
}
|
||||
|
||||
# Sub: _get_value
|
||||
# Get the value of the attribute (or one of its alternatives) from the event.
|
||||
# Undef is a valid value. If the attrib or none of its alternatives exist
|
||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 82;
|
||||
use Test::More;
|
||||
|
||||
use QueryRewriter;
|
||||
use EventAggregator;
|
||||
@@ -431,7 +431,7 @@ foreach my $event (@$events) {
|
||||
is_deeply( $ea->results, $result, 'user aggregation' );
|
||||
|
||||
is($ea->type_for('Query_time'), 'num', 'Query_time is numeric');
|
||||
$ea->calculate_statistical_metrics(apdex_t => 1);
|
||||
$ea->calculate_statistical_metrics();
|
||||
is_deeply(
|
||||
$ea->metrics(
|
||||
where => 'bob',
|
||||
@@ -446,8 +446,6 @@ is_deeply(
|
||||
median => '0.000682',
|
||||
stddev => 0,
|
||||
pct_95 => '0.000682',
|
||||
apdex_t => 1,
|
||||
apdex => '1.00',
|
||||
},
|
||||
'Got simple hash of metrics from metrics()',
|
||||
);
|
||||
@@ -466,8 +464,6 @@ is_deeply(
|
||||
median => 0,
|
||||
stddev => 0,
|
||||
pct_95 => 0,
|
||||
apdex_t => undef,
|
||||
apdex => undef,
|
||||
},
|
||||
'It does not crash on metrics()',
|
||||
);
|
||||
@@ -1816,59 +1812,6 @@ is_deeply(
|
||||
"Merge results"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Apdex
|
||||
# #############################################################################
|
||||
|
||||
my $samples = {
|
||||
280 => 10, # 0.81623354758492 satisfy
|
||||
281 => 10, # 0.85704522496417 satisfy
|
||||
282 => 10, # 0.89989748621238 satisfy
|
||||
283 => 50, # 0.94489236052300 satisfy
|
||||
284 => 50, # 0.99213697854915 satisfy
|
||||
285 => 10, # 1.04174382747661 tolerate
|
||||
290 => 10, # 1.32955843985657 tolerate
|
||||
313 => 1, # 4.08377033290049 frustrated
|
||||
};
|
||||
my $apdex = $ea->calculate_apdex(
|
||||
t => 1,
|
||||
samples => $samples,
|
||||
);
|
||||
|
||||
is(
|
||||
$apdex,
|
||||
'0.93',
|
||||
"Apdex score"
|
||||
);
|
||||
|
||||
$samples = {
|
||||
0 => 150,
|
||||
};
|
||||
$apdex = $ea->calculate_apdex(
|
||||
t => 1,
|
||||
samples => $samples,
|
||||
);
|
||||
|
||||
is(
|
||||
$apdex,
|
||||
'1.00',
|
||||
"Apdex score 1.00"
|
||||
);
|
||||
|
||||
$samples = {
|
||||
400 => 150,
|
||||
};
|
||||
$apdex = $ea->calculate_apdex(
|
||||
t => 1,
|
||||
samples => $samples,
|
||||
);
|
||||
|
||||
is(
|
||||
$apdex,
|
||||
'0.00',
|
||||
"Apdex score 0.00"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Special-case attribs called *_crc for mqd --variations.
|
||||
# #############################################################################
|
||||
@@ -1953,4 +1896,5 @@ like(
|
||||
qr/Complete test coverage/,
|
||||
'_d() works'
|
||||
);
|
||||
done_testing;
|
||||
exit;
|
||||
|
Reference in New Issue
Block a user