Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:46

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
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     #ax.invert_yaxis()
0111 
0112     plt.title(title)
0113 
0114     #ax.xaxis.set_visible(False)
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