-
Notifications
You must be signed in to change notification settings - Fork 3
/
cyclictest-post-process
executable file
·84 lines (77 loc) · 2.8 KB
/
cyclictest-post-process
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl
## -*- mode: perl; indent-tabs-mode: nil; perl-indent-level: 4 -*-
## vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=perl
use strict;
use warnings;
use JSON::XS;
use Data::Dumper;
use Getopt::Long;
BEGIN {
if (!(exists $ENV{'TOOLBOX_HOME'} && -d "$ENV{'TOOLBOX_HOME'}/perl")) {
print "This script requires libraries that are provided by the toolbox project.\n";
print "Toolbox can be acquired from https://github.com/perftool-incubator/toolbox and\n";
print "then use 'export TOOLBOX_HOME=/path/to/toolbox' so that it can be located.\n";
exit 1;
}
}
use lib "$ENV{'TOOLBOX_HOME'}/perl";
use toolbox::json;
use toolbox::metrics;
my $ignore;
GetOptions ("duration=s" => \$ignore,
"policy=s" => \$ignore,
"interval=i" => \$ignore,
"smt=s" => \$ignore,
);
my %metric_types;
my $primary_metric = 'wakeup-latency-usec';
my %times;
my $metric_data_name;
if (-e "begin.txt" && -e "end.txt") {
foreach my $i (qw(begin end)) {
my $file = $i . ".txt";
open(FH, $file) || die "Could not open " . $file;
$times{$i} = int (<FH> * 1000);
close FH;
}
} else {
printf "cyclictest-post-process(): could not find begin.txt and/or end.txt\n";
printf "Is the current directory for the cyclictest server (no result file)?\n";
exit 0;
}
my $result_file = "histogram.txt";
if ( -e $result_file) {
open(FH, $result_file) || die "Could not open file " . $result_file;
while (<FH>) {
# Max Latencies: 00013 00018 00005 00004 00005 00018 00017 00012 00008 00007 00004 00019 00005 00004 00019
if ( /^# Max Latencies:\s+(.*)$/ ) {
my @latencies = split(/\s+/, $1);
my $system_max_latency = pop(@latencies);
my %desc = ('source' => 'cyclictest', 'type' => $primary_metric, 'class' => 'count');
my %names = ();
my %sample = ('begin' => $times{'begin'}, 'end' => $times{'end'}, 'value' => int $system_max_latency);
log_sample("0", \%desc, \%names, \%sample);
}
}
$metric_data_name = finish_samples();
close(FH);
}
# Associate the metrics with a benchmark-period (in this case "measurement")
my %sample;
my @periods;
my @metrics = ( $metric_data_name );
my %period = ('name' => 'measurement');
$sample{'rickshaw-bench-metric'}{'schema'}{'version'} = "2021.04.12";
$period{'metric-files'} = \@metrics;
push(@periods, \%period);
$sample{'periods'} = \@periods;
$sample{'primary-period'} = 'measurement';
$sample{'primary-metric'} = $primary_metric;
$sample{'benchmark'} = 'cyclictest';
if (scalar @metrics > 0) {
my $coder = JSON::XS->new;
open(JSON_FH, ">post-process-data.json") ||
die("Could not open file post-process-data.json for writing\n");
print JSON_FH $coder->encode(\%sample);
close JSON_FH;
}