Skip to content

Commit c18d2d6

Browse files
authored
Merge pull request #2465 from kif/2459_dynamic_range_in_benchmark
dynamic range in benchmark
2 parents 72a9bf5 + be8f560 commit c18d2d6

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/pyFAI/benchmark/__init__.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"Benchmark for Azimuthal integration of PyFAI"
2525

2626
__author__ = "Jérôme Kieffer"
27-
__date__ = "21/05/2024"
27+
__date__ = "11/03/2025"
2828
__license__ = "MIT"
2929
__copyright__ = "2012-2024 European Synchrotron Radiation Facility, Grenoble, France"
3030

@@ -256,6 +256,7 @@ def __init__(self, nbr=10, repeat=1, memprofile=False, unit="2th_deg", max_size=
256256
self.unit = unit
257257
self.out_2d = (500, 360)
258258
self.max_size = max_size or sys.maxunicode
259+
self.plot_y_range = [1, 1000]
259260

260261
def get_cpu(self):
261262
if self._cpu is None:
@@ -363,7 +364,7 @@ def bench_1d(self, method="splitBBox", check=False, opencl=None, function="integ
363364
device = ' '.join(str(ocl.platforms[platformid].devices[deviceid]).split())
364365
print("Working on device: %s platform: %s device: %s" % (devicetype, platform, device))
365366
# label = ("%s %s %s %s %s" % (function, devicetype, self.LABELS[method.method[1:4]], platform, device)).replace(" ", "_")
366-
label = f'{devicetype}:{platform}:{device} / {function}: {method.split_lower}_{method.algo_lower}_{method.impl_lower}'
367+
label = f'{devicetype}:{platform}:{device} / {function}: ({method.split_lower},{method.algo_lower},{method.impl_lower})'
367368
method = IntegrationMethod.select_method(dim=1, split=method.split_lower,
368369
algo=method.algo_lower, impl=method.impl_lower,
369370
target=(opencl["platformid"], opencl["deviceid"]))[0]
@@ -639,24 +640,25 @@ def init_curve(self):
639640
self.ax.set_yscale("log", base=2)
640641
except Exception:
641642
self.ax.set_yscale("log", basey=2)
642-
t = [0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]
643+
t = [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000]
643644
self.ax.set_yticks([float(i) for i in t])
644645
self.ax.set_yticklabels([str(i)for i in t])
645646
self.ax.set_xlim(0.0, 20)
646-
self.ax.set_ylim(0.5, 1500)
647+
self.ax.set_ylim(0.75 * self.plot_y_range[0],
648+
1.5 * self.plot_y_range[1])
647649
self.ax.set_title(f'CPU: {self.get_cpu()}\nGPU: {self.get_gpu()}')
648650

649651
# Display detector markers (vertical lines)
650652
self.ax.vlines(
651653
x=data_sizes,
652-
ymin=self.ax.get_ylim()[0],
653-
ymax=self.ax.get_ylim()[1],
654+
ymin=0,
655+
ymax=100*self.plot_y_range[1],
654656
linestyles='dashed',
655657
alpha=0.4,
656658
colors='black',
657659
)
658660
for size, detector_label in zip(data_sizes, detector_names):
659-
self.ax.text(x=size, y=0.6, s=detector_label, rotation=270, fontsize=7)
661+
self.ax.text(x=size, y=0.8, s=detector_label, rotation=270, fontsize=7)
660662

661663
update_fig(self.fig)
662664

@@ -674,7 +676,11 @@ def new_curve(self, results, label, style="-", marker="x"):
674676
self.plot_x = list(results.keys())
675677
self.plot_x.sort()
676678
self.plot_y = [1000.0 / results[i] for i in self.plot_x]
679+
self.plot_y_range = [min(min(self.plot_y_range), min(self.plot_y)),
680+
max(max(self.plot_y_range), max(self.plot_y))]
677681
self.plot = self.ax.plot(self.plot_x, self.plot_y, marker + style, label=label)[0]
682+
self.ax.set_ylim(0.75 * self.plot_y_range[0],
683+
1.5 * self.plot_y_range[1])
678684

679685
handles, labels = self.ax.get_legend_handles_labels()
680686
self.ax.legend(
@@ -697,9 +703,14 @@ def new_point(self, size, exec_time):
697703
if not self.plot:
698704
return
699705

706+
y_value = 1000.0 / exec_time
700707
self.plot_x.append(size)
701-
self.plot_y.append(1000.0 / exec_time)
708+
self.plot_y.append(y_value)
702709
self.plot.set_data(self.plot_x, self.plot_y)
710+
self.plot_y_range = [min(self.plot_y_range[0], y_value),
711+
max(self.plot_y_range[1], y_value)]
712+
self.ax.set_ylim(0.75 * self.plot_y_range[0],
713+
1.5 * self.plot_y_range[1])
703714
update_fig(self.fig)
704715

705716
def display_all(self):

0 commit comments

Comments
 (0)