-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc_time.pl
48 lines (46 loc) · 1.14 KB
/
calc_time.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use strict;
use warnings;
my $line_count = shift;
my %result;
my @real;
my @user;
my @sys;
my $count=0;
while(<>) {
chomp;
my $line = $_;
my $min;
my $sec;
if ($line =~ /real.*(\d+)m(\d+.\d\d\d)s/) {
$min = $1;
$sec = $2;
push(@real, $min*60 + $sec);
} elsif ($line =~ /user.*(\d+)m(\d+.\d\d\d)s/) {
$min = $1;
$sec = $2;
push(@user, $min*60 + $sec);
} elsif ($line =~ /sys.*(\d+)m(\d+.\d\d\d)s/) {
$min = $1;
$sec = $2;
push(@sys, $min*60 + $sec);
}
}
$result{real} = \@real;
$result{user} = \@user;
$result{sys} = \@sys;
my %total;
my $array_count;
foreach my $c ('real','user','sys') {
my @r;
@r = sort @{$result{$c}};
shift @r; pop @r;
my $t=0.0;
$array_count = map {$t += $_ + 0.0} @r;
$total{$c} = $t;
}
printf "real : %7.3f\n", $total{real} / $array_count;
printf "user : %7.3f\n", $total{user} / $array_count;
printf "sys : %7.3f\n", $total{sys} / $array_count;
my $final_total = $total{real} + $total{user} + $total{sys};
printf "total: %7.3f\n", $final_total;
printf "qps: %7.3f\n", $line_count / $final_total if ($line_count);