/
make_percentile_plot
executable file
·95 lines (85 loc) · 2.56 KB
/
make_percentile_plot
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
86
87
88
89
90
91
92
93
94
#!/bin/sh
#
# * Written by Gil Tene of Azul Systems, and released to the public domain,
# * as explained at http://creativecommons.org/publicdomain/zero/1.0/
#
# This script uses gnuplot to plot the percentile distribution in the
# input files provided. run with "-h" option for an expected usage description.
#
# The script assumes the input files contain ".hgrm" formatted output such
# as the one provided by HdrHistogram. The 4th column in the input files is
# expected to be the value of 1/(1-percentile) (for a given percentile),
# and the 1st column in the input files is expected to be the value at the
# given percentile.
#
reading_SLA_NAME=0
reading_OUTPUT_NAME=0
helpFlagFound=0
SLA_NAME=
FILES=
OUTPUT_FILENAME=
reading_maxvalue=0
maxvalue=
for var in $@; do
if [ $reading_SLA_NAME -eq 1 ]; then
SLA_NAME=$var
reading_SLA_NAME=0
elif [ $reading_OUTPUT_NAME -eq 1 ]; then
OUTPUT_FILENAME=$var
reading_OUTPUT_NAME=0
elif [ $reading_maxvalue -eq 1 ]; then
maxvalue="set yrange [0:$var]"
reading_maxvalue=0
elif [ $var = "-h" ]; then
helpFlagFound=1
elif [ $var = "-o" ]; then
reading_OUTPUT_NAME=1
elif [ $var = "-s" ]; then
reading_SLA_NAME=1
elif [ $var = "-m" ]; then
reading_maxvalue=1
else
FILES="$FILES $var"
fi
done
message()
{
echo "$@" >&2
}
if [ $helpFlagFound -eq 1 ]; then
message "Usage: make_percentile_plot [-o output_file] [-s sla_file] histogram_file ..."
exit 255
fi
echo "1.0 0.0 0%" > ./xlabels.dat
echo "10.0 0.0 90%" >> ./xlabels.dat
echo "100.0 0.0 99%" >> ./xlabels.dat
echo "1000.0 0.0 99.9%" >> ./xlabels.dat
echo "10000.0 0.0 99.99%" >> ./xlabels.dat
echo "100000.0 0.0 99.999%" >> ./xlabels.dat
echo "1000000.0 0.0 99.9999%" >> ./xlabels.dat
echo "10000000.0 0.0 99.99999%" >> ./xlabels.dat
IndividualFilePlotCommands="'./xlabels.dat' with labels center offset 0, 1.5 point"
for file in $FILES; do
IndividualFilePlotCommands="$IndividualFilePlotCommands, '$file' using 4:1 with lines"
done
if [ $SLA_NAME ]; then
IndividualFilePlotCommands="$IndividualFilePlotCommands, '$SLA_NAME' with lines ls 1"
message plotting "{ " $FILES " }" with SLA $SLA_NAME
else
message plotting "{ " $FILES " }"
fi
message command will be:
message $IndividualFilePlotCommands
(
echo "#plot commands"
echo "set terminal png size 1280,720"
if [ $OUTPUT_FILENAME ]; then
echo "set output '$OUTPUT_FILENAME'"
fi
echo "set logscale x"
echo "unset xtics"
echo "$maxvalue"
echo "set key top left"
echo "set style line 1 lt 1 lw 3 pt 3 linecolor rgb \"red\""
echo "plot $IndividualFilePlotCommands"
) | gnuplot