summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Goetz <j.goetz@tecplot.com>2017-10-23 15:31:21 -0700
committerJohn Goetz <j.goetz@tecplot.com>2017-10-23 15:37:21 -0700
commit7f836c6d2583d882bebb2a60a623322f899b7875 (patch)
treebe21c2201c2e6762e0104d9e318ca18764232de3
parent288cbb33e4a50e165a3076e9d720f39d5d076ce8 (diff)
downloadnumpy-7f836c6d2583d882bebb2a60a623322f899b7875.tar.gz
BENCH: histogramming benchmarks
These benchmarks test filling histograms with uniform- linear binning in 1D and 2D, each with full coverage, where the histogram's range is the same as the sample data, with small coverage where the histogram's range is 1% of the sample data and finally with fine binning over the full range.
-rw-r--r--benchmarks/benchmarks/bench_function_base.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/benchmarks/benchmarks/bench_function_base.py b/benchmarks/benchmarks/bench_function_base.py
index 23103ba66..a45525793 100644
--- a/benchmarks/benchmarks/bench_function_base.py
+++ b/benchmarks/benchmarks/bench_function_base.py
@@ -5,6 +5,34 @@ from .common import Benchmark
import numpy as np
+class Histogram1D(Benchmark):
+ def setup(self):
+ self.d = np.linspace(0, 100, 100000)
+
+ def time_full_coverage(self):
+ np.histogram(self.d, 200, (0, 100))
+
+ def time_small_coverage(self):
+ np.histogram(self.d, 200, (50, 51))
+
+ def time_fine_binning(self):
+ np.histogram(self.d, 10000, (0, 100))
+
+
+class Histogram2D(Benchmark):
+ def setup(self):
+ self.d = np.linspace(0, 100, 200000).reshape((-1,2))
+
+ def time_full_coverage(self):
+ np.histogramdd(self.d, (200, 200), ((0, 100), (0, 100)))
+
+ def time_small_coverage(self):
+ np.histogramdd(self.d, (200, 200), ((50, 51), (50, 51)))
+
+ def time_fine_binning(self):
+ np.histogramdd(self.d, (10000, 10000), ((0, 100), (0, 100)))
+
+
class Bincount(Benchmark):
def setup(self):
self.d = np.arange(80000, dtype=np.intp)