mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-10 07:14:05 +00:00
24 lines
2.4 KiB
Plaintext
24 lines
2.4 KiB
Plaintext
[section:benchmarks Benchmarks]
|
|
|
|
The library is designed to be fast. While it is unlikely that the time spend in the histogram is limiting an application, we cannot predict how the library is used.
|
|
|
|
The following plot shows results of a benchmark on a 9 GHz Macbook Pro. Random numbers from a uniform and a normal distribution are filled into the histograms of 1, 3, and 6 dimensions. 100 bins are used for 1D, 100x100x100=10^6 for 3D, and 10x10x10x10x10x10=10^6 for 6D. Each test is repeated 50 times and the minimum time is taken.
|
|
|
|
[$benchmark.png [width 5in] [height 5in]]
|
|
|
|
[variablelist Plot legend:
|
|
[[root] [[@https://root.cern.ch ROOT classes] (`TH1I` for 1D, `TH3I` for 3D and `THnI` for 6D)]]
|
|
[[py:numpy] [numpy functions ([python]`numpy.histogram1d` for 1D, `numpy.histogramdd` for 3D and 6D)]]
|
|
[[py:hd_sd] [[classref boost::histogram::dynamic_histogram dynamic_histogram] with [classref boost::histogram::adaptive_storage adaptive_storage] called from Python]]
|
|
[[hs_ss] [[classref boost::histogram::static_histogram static_histogram] with [classref boost::histogram::container_storage<std::vector<int>> container_storage<std::vector<int>>]]]
|
|
[[hs_sd] [[classref boost::histogram::static_histogram static_histogram] with [classref boost::histogram::adaptive_storage adaptive_storage]]]
|
|
[[hd_ss] [[classref boost::histogram::dynamic_histogram dynamic_histogram] with [classref boost::histogram::container_storage<std::vector<int>> container_storage<std::vector<int>>]]]
|
|
[[hd_sd] [[classref boost::histogram::dynamic_histogram dynamic_histogram] with [classref boost::histogram::adaptive_storage adaptive_storage]]]
|
|
|
|
]
|
|
|
|
[classref boost::histogram::static_histogram static_histogram] is always faster than [classref boost::histogram::dynamic_histogram dynamic_histogram] and safer to use, as more checks are done at compile time. It is recommended when working in C++ only. [classref boost::histogram::adaptive_storage adaptive_storage] is faster than [classref boost::histogram::container_storage container_storage] for larger histograms, because it uses the cache more effectively due to its smaller memory consumption per bin.
|
|
|
|
The histograms in this library are mostly faster than the competition, in some cases by a factor of 2. Simultaneously they are more flexible, since binning strategies can be exchanged. The Python-wrapped histogram is slower than numpy's own specialized function for 1D, but beats numpy's general multi-dimensional function by a factor 2 to 3.
|
|
|
|
[endsect] |