-
Notifications
You must be signed in to change notification settings - Fork 3
/
fio-post-process
executable file
·85 lines (83 loc) · 3.49 KB
/
fio-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
85
#!/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;
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;
opendir(my $dh, ".");
for my $log_file (sort readdir($dh)) {
if ($log_file =~ /fio_([a-z]+)\.(\d+)\.log(\.xz){0,1}$/) {
printf "found file %s\n", $log_file;
my @logfile_metrics;
my $type = $1;
my $job_id = $2;
my %names = ('job' => $job_id);
my %desc = ();
if ($type eq "iops" ) {
%desc = ('source' => 'fio', 'class' => 'throughput', 'type' => 'iops');
} elsif ($type eq "bw") {
%desc = ('source' => 'fio', 'class' => 'throughput', 'type' => 'bw-KiBs');
} elsif ($type eq "lat") {
%desc = ('source' => 'fio', 'class' => 'count', 'type' => 'latency-usec');
} elsif ($type eq "clat") {
%desc = ('source' => 'fio', 'class' => 'count', 'type' => 'completion-latency-usec');
} elsif ($type eq "slat") {
%desc = ('source' => 'fio', 'class' => 'count', 'type' => 'submission-latency-usec');
} else {
printf "fio log file %s not recognized, skippping\n", $type;
}
if (defined $desc{'type'}) {
#open(my $log_fh, $log_file) || die "[ERROR]could not open file " . $log_file;
(my $rc, my $log_fh) = open_read_text_file($log_file);
die "[ERROR]could not open file " . $log_file if ($rc > 0);
while (<$log_fh>) {
if ( /^(\d+),\s+(\d+),\s+(\d+),\s+(\d+)/ ) {
my $timestamp_ms = $1;
my $value = $2;
my $io_oper = $3;
continue if ($io_oper > 2);
s/0/Read/, s/1/Write/, s/2/Trim/ for $io_oper;
$names{'cmd'} = $io_oper;
my %s = ('end' => int $timestamp_ms, 'value' => $value);
log_sample("0", \%desc, \%names, \%s);
}
}
close($log_fh);
}
} else {
printf "Not considering %s for processing\n", $log_file;
}
}
my $metric_data_name = finish_samples();
# In any benchmark post-process script, the metrics generated need to be attributed to a
# time-period (AKA benchmark-phase). The period which is used to report and offical
# result for the benchmark is the 'measurement' period. Ohter periods thay may exist
# could be "warm-up", "prep", etc.
my %sample;
my @periods;
my %period = ('name' => 'measurement');
my @metric_files = ( $metric_data_name );
$period{'metric-files'} = \@metric_files;
push(@periods, \%period);
$sample{'primary-metric'} = "iops";
$sample{'primary-period'} = "measurement";
$sample{'benchmark'} = "fio";
$sample{'periods'} = \@periods;
$sample{'rickshaw-bench-metric'}{'schema'}{'version'} = "2021.04.12";
closedir $dh;
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;