File indexing completed on 2026-04-09 07:48:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022 benchplot.py
0023 ============
0024
0025 ::
0026
0027 ip benchplot.py --name geocache-bench360 --include xanalytic --include 10240,5760,1
0028
0029
0030 """
0031
0032 import os, logging, sys
0033 from collections import OrderedDict as odict
0034 import numpy as np
0035 log = logging.getLogger(__name__)
0036
0037 from opticks.ana.bench import Bench
0038 from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable
0039 import matplotlib.pyplot as plt
0040
0041 from opticks.ana.plot import init_rcParams
0042 init_rcParams(plt)
0043
0044
0045 def barplot(labels, values):
0046 """
0047 """
0048 iso = np.argsort( values )
0049
0050 ivalues = (values*100).astype(np.int)
0051
0052
0053 cmap = plt.get_cmap('RdYlGn')( np.linspace(0.15, 0.85, 100))
0054 color = cmap[ivalues]
0055
0056
0057
0058 widths = values
0059 starts = 0
0060 ax.barh(labels[iso], widths[iso], left=starts, height=0.5, color=color[iso])
0061 xcenters = starts + widths - 0.1
0062
0063
0064 fmt_ = lambda _:"%10.3f" % _
0065
0066 for y, (x, c) in enumerate(zip(xcenters, widths)):
0067
0068 r, g, b, _ = color[y]
0069 text_color = 'white' if r * g * b < 0.5 else 'darkgrey'
0070 text_color = 'black'
0071
0072 ax.text(x, y, fmt_(c), ha='center', va='center', color=text_color)
0073 pass
0074 return fig, ax
0075
0076
0077 if __name__ == '__main__':
0078
0079 logging.basicConfig(level=logging.INFO)
0080
0081 ratios = odict()
0082 ratios["R0/1_TITAN_V"] = "R0_TITAN_V R1_TITAN_V".split()
0083 ratios["R0/1_TITAN_RTX"] = "R0_TITAN_RTX R1_TITAN_RTX".split()
0084 ratios["R1/0_TITAN_V"] = "R1_TITAN_V R0_TITAN_V".split()
0085 ratios["R1/0_TITAN_RTX"] = "R1_TITAN_RTX R0_TITAN_RTX".split()
0086
0087 args = Bench.Args()
0088 args.ratios = ratios
0089
0090 b = Bench(args)
0091 print(b)
0092
0093
0094 titles = odict()
0095 titles["20190526_143808"] = "JUNO360 raytrace with 1/2/4/8 NVIDIA Tesla GV100 GPUs "
0096 titles["20190526_202537"] = "JUNO360 raytrace with NVIDIA TITAN V and TITAN RTX GPUs"
0097
0098 df = titles.keys()[1]
0099
0100 rg = b.find(df)
0101 title = titles.get(df, "benchplot")
0102 xlabel = "RO:RTX OFF, R1:RTX ON Time(s) to raytrace 10240 x 5760 (59M) pixels "
0103
0104
0105 labels = rg.a.label
0106 values = rg.a.metric
0107
0108 fig = plt.figure()
0109 ax = fig.add_subplot(111)
0110
0111
0112 plt.title(title)
0113
0114
0115 ax.set_xlim(0, values.max()*1.1 )
0116
0117 ax.set_xlabel( xlabel )
0118
0119
0120 fig, ax = barplot(labels, values)
0121 make_axes_area_auto_adjustable(ax)
0122
0123 plt.ion()
0124 plt.show()
0125
0126 print("savefig %s " % rg.path)
0127 plt.savefig(rg.path)
0128
0129
0130
0131
0132
0133