13 set terminal png size 1024, 768
15 set title "re2 benchlog"
16 set datafile separator ";"
22 template =
"""'{}' using 1:5:xticlabels(2) with linespoints linewidth 3 title "{}",\\\n"""
32 remove all temporary files
40 parse the input benchlog and return a dictionary contain bench data
45 with open(filename)
as f:
47 for raw
in f.readlines():
49 data = raw.split(
'\t')
53 data = data[0].
split(
'/') + data[1:]
54 data = list(
map(str.strip, data))
56 if not benchdata.get(data[0]):
57 benchdata[data[0]] = [ data[1:] ]
59 benchdata[data[0]].append(data[1:])
63 generate temporary csv files
68 with tempfile.NamedTemporaryFile(delete=
False)
as f:
70 for index, line
in enumerate(data):
71 f.write(
'{};{}\n'.
format(index,
';'.join(line)).
encode())
79 command = subprocess.Popen([
'gnuplot'], stdin=subprocess.PIPE)
80 command.communicate(script.encode())
83 if __name__ ==
'__main__':
85 parser = argparse.ArgumentParser(description=
'generate plots for benchlog')
86 parser.add_argument(
'benchlog', type=str, help=
'benchlog generated by re2')
87 args = parser.parse_args()
90 subprocess.Popen([
'gnuplot'], stdin=subprocess.PIPE)
91 except FileNotFoundError:
92 print(
'you can install "gnuplot" to generate plots automatically')
96 plot.output = args.benchlog
97 plot.parse_re2_benchlog(args.benchlog)