Skip to content

Commit

Permalink
BENCH: histogramming benchmarks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
theodoregoetz committed Oct 23, 2017
1 parent 288cbb3 commit 7f836c6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions benchmarks/benchmarks/bench_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@
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)
Expand Down

0 comments on commit 7f836c6

Please sign in to comment.