summaryrefslogtreecommitdiff
path: root/benchmark.py
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark.py')
-rwxr-xr-xbenchmark.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/benchmark.py b/benchmark.py
index 31c145c..329986c 100755
--- a/benchmark.py
+++ b/benchmark.py
@@ -14,6 +14,7 @@ from chroma import sample
from chroma import generator
from chroma import tools
from chroma import optics
+from chroma.transform import normalize
# Generator processes need to fork BEFORE the GPU context is setup
g4generator = generator.photon.G4ParallelGenerator(4, optics.water_wcsim)
@@ -46,8 +47,7 @@ def load_photons(number=100, nphotons=500000):
per second."""
pos = np.zeros((nphotons,3))
dir = sample.uniform_sphere(nphotons)
- pol = np.cross(sample.uniform_sphere(nphotons), dir)
- pol /= np.apply_along_axis(np.linalg.norm,1,pol)[:,np.newaxis]
+ pol = normalize(np.cross(sample.uniform_sphere(nphotons), dir))
wavelengths = np.random.uniform(400,800,size=nphotons)
photons = event.Photons(pos, dir, pol, wavelengths)
@@ -73,8 +73,7 @@ def propagate(gpu_geometry, number=10, nphotons=500000, nthreads_per_block=64,
for i in tools.progress(range(number)):
pos = np.zeros((nphotons,3))
dir = sample.uniform_sphere(nphotons)
- pol = np.cross(sample.uniform_sphere(nphotons), dir)
- pol /= np.apply_along_axis(np.linalg.norm,1,pol)[:,np.newaxis]
+ pol = normalize(np.cross(sample.uniform_sphere(nphotons), dir))
wavelengths = np.random.uniform(400,800,size=nphotons)
photons = event.Photons(pos, dir, pol, wavelengths)
gpu_photons = gpu.GPUPhotons(photons)