Skip to content

Instantly share code, notes, and snippets.

@manodeep
Created July 25, 2017 03:36
Show Gist options
  • Save manodeep/a354798878d9046c18e6eb216de616c1 to your computer and use it in GitHub Desktop.
Save manodeep/a354798878d9046c18e6eb216de616c1 to your computer and use it in GitHub Desktop.
Benchmark my fork of Tom Robitaille's fast-histogram code
from __future__ import print_function
import numpy as np
from fast_histogram import histogram1d, histogram1d_wrapper
np.random.seed(42)
npoints=np.array([1, 10, 100])*1000000
for n in npoints:
x = np.random.random(n)
_ = histogram1d_wrapper(x, range=[-1, 2], bins=30)
#################################################################################################################
# FUNCTION Npoints (x10^6) Avg_time Sigma_time Best_time
#################################################################################################################
base 1 0.0027 0.0005 0.0022
base (unroll 2) 1 0.0026 0.0006 0.0022
base (unroll 4) 1 0.0026 0.0007 0.0021
base (unroll 4, indp) 1 0.0022 0.0006 0.0019
pointers 1 0.0041 0.0009 0.0029
No branching 1 0.0042 0.0008 0.0030
No branching, pointers 1 0.0031 0.0006 0.0027
No branching, pointers (unroll 2) 1 0.0031 0.0006 0.0022
No branching, pointers (unroll 2, indp)) 1 0.0027 0.0005 0.0022
No branching, pointers (unroll 4) 1 0.0028 0.0009 0.0022
No branching, pointers (unroll 4, indp) 1 0.0029 0.0007 0.0021
#################################################################################################################
# FUNCTION Npoints (x10^6) Avg_time Sigma_time Best_time
#################################################################################################################
base 10 0.0259 0.0010 0.0241
base (unroll 2) 10 0.0248 0.0018 0.0232
base (unroll 4) 10 0.0281 0.0051 0.0232
base (unroll 4, indp) 10 0.0218 0.0014 0.0197
pointers 10 0.0250 0.0010 0.0235
No branching 10 0.0272 0.0018 0.0250
No branching, pointers 10 0.0265 0.0017 0.0241
No branching, pointers (unroll 2) 10 0.0235 0.0019 0.0207
No branching, pointers (unroll 2, indp)) 10 0.0238 0.0019 0.0208
No branching, pointers (unroll 4) 10 0.0220 0.0013 0.0204
No branching, pointers (unroll 4, indp) 10 0.0227 0.0018 0.0201
#################################################################################################################
# FUNCTION Npoints (x10^6) Avg_time Sigma_time Best_time
#################################################################################################################
base 100 0.2536 0.0041 0.2448
base (unroll 2) 100 0.2463 0.0024 0.2428
base (unroll 4) 100 0.2375 0.0037 0.2329
base (unroll 4, indp) 100 0.2163 0.0061 0.2095
pointers 100 0.2528 0.0044 0.2461
No branching 100 0.2634 0.0177 0.2482
No branching, pointers 100 0.2567 0.0077 0.2478
No branching, pointers (unroll 2) 100 0.2287 0.0047 0.2211
No branching, pointers (unroll 2, indp)) 100 0.2288 0.0038 0.2216
No branching, pointers (unroll 4) 100 0.2225 0.0032 0.2174
No branching, pointers (unroll 4, indp) 100 0.2277 0.0120 0.2186
@manodeep
Copy link
Author

@astrofrog Here are my timings from the perf branch here. 10-20% faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment