histogram/benchmark/histogram_filling_numpy.py
Hans Dembinski 92a873c746
Faster linearize (#230)
* introduce offset for faster linearization of non-growing axes
* added traits::is_inclusive and constexpr bool inclusive() methods for builtin axes
* bug fixes for fill method when weight array is used with non-inclusive axis and when growing axes are used
* bug fix of axis::options::test(...)
* coverage tested with gcc-8, updated CONTRIBUTING.md with coverage info
2019-10-06 23:03:45 +02:00

14 lines
526 B
Python

from __future__ import print_function
import numpy as np
# pip install fast-histogram
from fast_histogram import histogram1d
import timeit
x = np.random.rand(1 << 20)
nrepeat = 10
print(timeit.timeit("np.histogram(x, bins=100, range=(0, 1))",
"from __main__ import x, np", number=nrepeat) / (nrepeat * len(x)) / 1e-9)
print(timeit.timeit("histogram1d(x, bins=100, range=(0, 1))",
"from __main__ import x, histogram1d", number=nrepeat) / (nrepeat * len(x)) / 1e-9)