diff options
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/benchmarks/bench_core.py | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/benchmarks/benchmarks/bench_core.py b/benchmarks/benchmarks/bench_core.py index 08e21cc8c..b595ae469 100644 --- a/benchmarks/benchmarks/bench_core.py +++ b/benchmarks/benchmarks/bench_core.py @@ -2,78 +2,78 @@ from __future__ import absolute_import, division, print_function from .common import Benchmark -import numpy +import numpy as np class Core(Benchmark): def setup(self): self.l100 = range(100) self.l50 = range(50) - self.l = [numpy.arange(1000), numpy.arange(1000)] - self.l10x10 = numpy.ones((10, 10)) + self.l = [np.arange(1000), np.arange(1000)] + self.l10x10 = np.ones((10, 10)) def time_array_1(self): - numpy.array(1) + np.array(1) def time_array_empty(self): - numpy.array([]) + np.array([]) def time_array_l1(self): - numpy.array([1]) + np.array([1]) def time_array_l100(self): - numpy.array(self.l100) + np.array(self.l100) def time_array_l(self): - numpy.array(self.l) + np.array(self.l) def time_vstack_l(self): - numpy.vstack(self.l) + np.vstack(self.l) def time_hstack_l(self): - numpy.hstack(self.l) + np.hstack(self.l) def time_dstack_l(self): - numpy.dstack(self.l) + np.dstack(self.l) def time_arange_100(self): - numpy.arange(100) + np.arange(100) def time_zeros_100(self): - numpy.zeros(100) + np.zeros(100) def time_ones_100(self): - numpy.ones(100) + np.ones(100) def time_empty_100(self): - numpy.empty(100) + np.empty(100) def time_eye_100(self): - numpy.eye(100) + np.eye(100) def time_identity_100(self): - numpy.identity(100) + np.identity(100) def time_eye_3000(self): - numpy.eye(3000) + np.eye(3000) def time_identity_3000(self): - numpy.identity(3000) + np.identity(3000) def time_diag_l100(self): - numpy.diag(self.l100) + np.diag(self.l100) def time_diagflat_l100(self): - numpy.diagflat(self.l100) + np.diagflat(self.l100) def time_diagflat_l50_l50(self): - numpy.diagflat([self.l50, self.l50]) + np.diagflat([self.l50, self.l50]) def time_triu_l10x10(self): - numpy.triu(self.l10x10) + np.triu(self.l10x10) def time_tril_l10x10(self): - numpy.tril(self.l10x10) + np.tril(self.l10x10) class MA(Benchmark): @@ -82,10 +82,27 @@ class MA(Benchmark): self.t100 = ([True] * 100) def time_masked_array(self): - numpy.ma.masked_array() + np.ma.masked_array() def time_masked_array_l100(self): - numpy.ma.masked_array(self.l100) + np.ma.masked_array(self.l100) def time_masked_array_l100_t100(self): - numpy.ma.masked_array(self.l100, self.t100) + np.ma.masked_array(self.l100, self.t100) + + +class CorrConv(Benchmark): + params = [[50, 1000, 1e5], + [10, 100, 1000, 1e4], + ['valid', 'same', 'full']] + param_names = ['size1', 'size2', 'mode'] + + def setup(self, size1, size2, mode): + self.x1 = np.linspace(0, 1, num=size1) + self.x2 = np.cos(np.linspace(0, 2*np.pi, num=size2)) + + def time_correlate(self, size1, size2, mode): + np.correlate(self.x1, self.x2, mode=mode) + + def time_convolve(self, size1, size2, mode): + np.convolve(self.x1, self.x2, mode=mode) |