]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/histogram/benchmark/plot_benchmarks.py
3 # Copyright Hans Dembinski 2019
4 # Distributed under the Boost Software License, Version 1.0.
5 # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
7 from matplotlib
import pyplot
as plt
, lines
10 import subprocess
as subp
12 from collections
import defaultdict
13 from run_benchmarks
import get_commits
, run
20 commits
, comments
= get_commits()
22 def get_benchmarks(results
):
23 benchmarks
= defaultdict(lambda: [])
25 if hash in results
and results
[hash] is not None:
26 benchs
= results
[hash]
27 for b
in benchs
["benchmarks"]:
29 time
= min(b
["cpu_time"], b
["real_time"])
30 benchmarks
[name
].append((commits
.index(hash), time
))
33 with shelve
.open("benchmark_results") as results
:
34 benchmarks
= get_benchmarks(results
)
36 fig
, ax
= plt
.subplots(4, 1, figsize
=(10, 10), sharex
=True)
37 plt
.subplots_adjust(hspace
=0, top
=0.98, bottom
=0.05, right
=0.96)
40 for name
, xy
in benchmarks
.items():
41 if "uniform" in name
: continue
43 x
, y
= np
.transpose(xy
)
44 plt
.plot(x
, y
, ".-", label
=name
)
45 plt
.legend(fontsize
="xx-small")
48 for name
, xy
in benchmarks
.items():
49 if "uniform" in name
: continue
51 x
, y
= np
.transpose(xy
)
52 plt
.plot(x
, y
, ".-", label
=name
)
53 plt
.legend(fontsize
="xx-small")
56 for name
, xy
in benchmarks
.items():
57 if "uniform" in name
: continue
59 x
, y
= np
.transpose(xy
)
60 plt
.plot(x
, y
, ".-", label
=name
)
61 plt
.legend(fontsize
="xx-small")
64 for name
, xy
in benchmarks
.items():
65 if "uniform" in name
: continue
67 x
, y
= np
.transpose(xy
)
68 plt
.plot(x
, y
, ".-", label
=name
)
69 plt
.legend(fontsize
="xx-small")
71 plt
.figtext(0.01, 0.5, "time per loop / ns [smaller is better]", rotation
=90, va
="center")
73 def format_coord(x
, y
):
75 current_index
= max(0, min(int(x
+ 0.5), len(commits
) - 1))
76 hash = commits
[current_index
]
77 comment
= comments
[hash]
78 return f
"{hash} {comment}"
80 for axi
in ax
.flatten():
81 axi
.format_coord
= format_coord
83 def on_key_press(event
):
85 if thread
and thread
.is_alive(): return
87 if event
.key
!= "u": return
89 hash = commits
[current_index
]
91 def worker(fig
, ax
, hash):
92 with shelve
.open("benchmark_results") as results
:
93 run(results
, comments
, hash, True)
94 benchmarks
= get_benchmarks(results
)
96 for name
in benchmarks
:
98 x
, y
= np
.transpose(xy
)
99 for axi
in ax
.flatten():
100 for artist
in axi
.get_children():
101 if isinstance(artist
, lines
.Line2D
) and artist
.get_label() == name
:
107 thread
= threading
.Thread(target
=worker
, args
=(fig
, ax
, hash))
110 fig
.canvas
.mpl_connect('key_press_event', on_key_press
)