Skip to content

Commit df2f998

Browse files
authored
Merge pull request #2147 from silx-kit/update_benchmark
Improve benchmarks:
2 parents d2cef7c + 3a62d57 commit df2f998

File tree

1 file changed

+22
-35
lines changed

1 file changed

+22
-35
lines changed

src/pyFAI/benchmark/__init__.py

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# coding: utf-8
33
#
4-
# Copyright (C) 2016-2023 European Synchrotron Radiation Facility, Grenoble, France
4+
# Copyright (C) 2016-2024 European Synchrotron Radiation Facility, Grenoble, France
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal
@@ -24,9 +24,9 @@
2424
"Benchmark for Azimuthal integration of PyFAI"
2525

2626
__author__ = "Jérôme Kieffer"
27-
__date__ = "20/12/2023"
27+
__date__ = "25/04/2024"
2828
__license__ = "MIT"
29-
__copyright__ = "2012-2017 European Synchrotron Radiation Facility, Grenoble, France"
29+
__copyright__ = "2012-2024 European Synchrotron Radiation Facility, Grenoble, France"
3030

3131
from collections import OrderedDict
3232
import json
@@ -39,10 +39,9 @@
3939
import fabio
4040
import os.path as op
4141
from math import ceil
42+
import numpy
4243

43-
# To use use the locally build version of PyFAI, use ../bootstrap.py
44-
45-
from .. import load
44+
from .. import load, detector_factory
4645
from ..azimuthalIntegrator import AzimuthalIntegrator
4746
from ..method_registry import IntegrationMethod, Method
4847
from ..utils import mathutil
@@ -62,35 +61,22 @@ def update_fig(*args, **kwargs):
6261
def update_fig(*args, **kwargs):
6362
pass
6463

65-
ds_list = ["Pilatus1M.poni",
66-
"Pilatus2M.poni",
67-
"Eiger4M.poni",
68-
"Pilatus6M.poni",
69-
"Eiger9M.poni",
70-
"Mar3450.poni",
71-
"Fairchild.poni"]
72-
7364
detector_names = ["Pilatus1M",
7465
"Pilatus2M",
7566
"Eiger4M",
7667
"Pilatus6M",
7768
"Eiger9M",
7869
"Mar3450",
79-
"Fairchild",]
70+
"Fairchild", ]
8071

81-
data_sizes = [1.023183,
82-
2.476525,
83-
4.48569,
84-
6.224001,
85-
10.138296,
86-
11.9025,
87-
16.777216,
88-
] #Mpixels
72+
ds_list = [d + ".poni" for d in detector_names]
8973

74+
data_sizes = [numpy.prod(detector_factory(d).shape) * 1e-6
75+
for d in detector_names]
9076

9177
datasets = {"Fairchild.poni": "Fairchild.edf",
92-
"halfccd.poni": "halfccd.edf",
93-
"Frelon2k.poni": "Frelon2k.edf",
78+
# "halfccd.poni": "halfccd.edf",
79+
# "Frelon2k.poni": "Frelon2k.edf",
9480
"Pilatus6M.poni": "Pilatus6M.cbf",
9581
"Pilatus1M.poni": "Pilatus1M.edf",
9682
"Mar3450.poni": "LaB6_260210.mar3450",
@@ -99,7 +85,6 @@ def update_fig(*args, **kwargs):
9985
"Eiger9M.poni":"Eiger9M.h5"
10086
}
10187

102-
10388
PONIS = { i: UtilsTest.getimage(i) for i in ds_list}
10489

10590
# Handle to the Bench instance: allows debugging from outside if needed
@@ -138,7 +123,6 @@ def get_device(self):
138123
res = None
139124
if "ai" in dir(self):
140125
if "engines" in dir(self.ai):
141-
from ..method_registry import Method
142126
for method in self.ai.engines:
143127
if isinstance(method, Method) and method.impl == "opencl":
144128
res = self.ai.engines[method].engine.ctx.devices[0]
@@ -249,9 +233,12 @@ def __init__(self, nbr=10, repeat=1, memprofile=False, unit="2th_deg", max_size=
249233
self.LIMIT = 8
250234
self.repeat = repeat
251235
self.nbr = nbr
252-
self.results = OrderedDict()
253-
self.meth = []
254236
self._cpu = None
237+
self.results = {"host": platform.node(),
238+
"argv": sys.argv,
239+
"cpu": self.get_cpu(),
240+
"gpu": self.get_gpu()}
241+
self.meth = []
255242
self.fig = None
256243
self.ax = None
257244
self.starttime = time.perf_counter()
@@ -521,10 +508,10 @@ def bench_2d(self, method="splitBBox", check=False, opencl=None):
521508
if check:
522509
module = sys.modules.get(AzimuthalIntegrator.__module__)
523510
if module:
524-
if "lut" in method.algo_lower: # Edgar
511+
if "lut" in method.algo_lower: # Edgar
525512
# if "lut" in method:
526513
key = module.EXT_LUT_ENGINE
527-
elif "csr" in method.algo_lower: # Edgar
514+
elif "csr" in method.algo_lower: # Edgar
528515
# elif "csr" in method:
529516
key = module.EXT_CSR_ENGINE
530517
else:
@@ -619,7 +606,7 @@ def bench_gpu1d(self, devicetype="gpu", useFp64=True, platformid=None, deviceid=
619606

620607
def save(self, filename=None):
621608
if filename is None:
622-
filename = f"benchmark{time.strftime('%Y%m%d-%H%M%S')}.json"
609+
filename = f"benchmark-{time.strftime('%Y%m%d-%H%M%S')}.json"
623610
self.update_mp()
624611
json.dump(self.results, open(filename, "w"), indent=4)
625612
if self.fig is not None:
@@ -638,7 +625,7 @@ def init_curve(self):
638625
print("Already initialized")
639626
return
640627
if pyplot and ((sys.platform in ["win32", "darwin"]) or ("DISPLAY" in os.environ)):
641-
self.fig, self.ax = pyplot.subplots(figsize=(12,6))
628+
self.fig, self.ax = pyplot.subplots(figsize=(12, 6))
642629
self.fig.show()
643630
self.ax.set_autoscale_on(False)
644631
self.ax.set_xlabel("Image size in mega-pixels")
@@ -689,7 +676,7 @@ def new_curve(self, results, label, style="-", marker="x"):
689676
self.ax.legend(
690677
handles=handles,
691678
loc='center left',
692-
bbox_to_anchor=(1.05,0.5),
679+
bbox_to_anchor=(1.05, 0.5),
693680
fontsize=10,
694681
)
695682
self.fig.subplots_adjust(right=0.5)
@@ -790,7 +777,7 @@ def run_benchmark(number=10, repeat=1, memprof=False, max_size=1000,
790777
ocl_devices = []
791778
if ocl:
792779
try:
793-
ocl_devices = [(int(i), int(j)) for i,j in devices]
780+
ocl_devices = [(int(i), int(j)) for i, j in devices]
794781
except Exception as err:
795782
# print(f"{type(err)}: {err}\ndevices is not a list of 2-tuple of integrers, parsing the list")
796783
ocl_devices = []

0 commit comments

Comments
 (0)