summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@google.com>2018-09-24 08:46:49 -0700
committerStephan Hoyer <shoyer@google.com>2018-09-24 08:46:49 -0700
commit1846ac335da808cb8bf6f9b1950933348a40d200 (patch)
tree293832d9315d9656d6d865865e53a75ca7fd62ff /benchmarks
parent0da1b95ea9180ab613eccc80ebe39eb4f48d99d3 (diff)
downloadnumpy-1846ac335da808cb8bf6f9b1950933348a40d200.tar.gz
CLN: remove the internal Benchmark class
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmarks/bench_app.py6
-rw-r--r--benchmarks/benchmarks/bench_core.py16
-rw-r--r--benchmarks/benchmarks/bench_function_base.py18
-rw-r--r--benchmarks/benchmarks/bench_indexing.py8
-rw-r--r--benchmarks/benchmarks/bench_io.py22
-rw-r--r--benchmarks/benchmarks/bench_lib.py8
-rw-r--r--benchmarks/benchmarks/bench_linalg.py8
-rw-r--r--benchmarks/benchmarks/bench_ma.py10
-rw-r--r--benchmarks/benchmarks/bench_overrides.py4
-rw-r--r--benchmarks/benchmarks/bench_random.py12
-rw-r--r--benchmarks/benchmarks/bench_reduce.py12
-rw-r--r--benchmarks/benchmarks/bench_shape_base.py6
-rw-r--r--benchmarks/benchmarks/bench_ufunc.py18
-rw-r--r--benchmarks/benchmarks/common.py4
14 files changed, 66 insertions, 86 deletions
diff --git a/benchmarks/benchmarks/bench_app.py b/benchmarks/benchmarks/bench_app.py
index ccf6e4c4a..bc217c3ec 100644
--- a/benchmarks/benchmarks/bench_app.py
+++ b/benchmarks/benchmarks/bench_app.py
@@ -1,13 +1,11 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
import numpy as np
from six.moves import xrange
-class LaplaceInplace(Benchmark):
+class LaplaceInplace(object):
params = ['inplace', 'normal']
param_names = ['update']
@@ -53,7 +51,7 @@ class LaplaceInplace(Benchmark):
self.run()
-class MaxesOfDots(Benchmark):
+class MaxesOfDots(object):
def setup(self):
np.random.seed(1)
nsubj = 5
diff --git a/benchmarks/benchmarks/bench_core.py b/benchmarks/benchmarks/bench_core.py
index 26cffcab1..b6cbd9350 100644
--- a/benchmarks/benchmarks/bench_core.py
+++ b/benchmarks/benchmarks/bench_core.py
@@ -1,11 +1,9 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
import numpy as np
-class Core(Benchmark):
+class Core(object):
def setup(self):
self.l100 = range(100)
self.l50 = range(50)
@@ -76,7 +74,7 @@ class Core(Benchmark):
np.tril(self.l10x10)
-class Temporaries(Benchmark):
+class Temporaries(object):
def setup(self):
self.amid = np.ones(50000)
self.bmid = np.ones(50000)
@@ -96,7 +94,7 @@ class Temporaries(Benchmark):
(self.alarge + self.blarge) - 2
-class CorrConv(Benchmark):
+class CorrConv(object):
params = [[50, 1000, 1e5],
[10, 100, 1000, 1e4],
['valid', 'same', 'full']]
@@ -113,7 +111,7 @@ class CorrConv(Benchmark):
np.convolve(self.x1, self.x2, mode=mode)
-class CountNonzero(Benchmark):
+class CountNonzero(object):
param_names = ['numaxes', 'size', 'dtype']
params = [
[1, 2, 3],
@@ -137,7 +135,7 @@ class CountNonzero(Benchmark):
self.x.ndim - 1, self.x.ndim - 2))
-class PackBits(Benchmark):
+class PackBits(object):
param_names = ['dtype']
params = [[bool, np.uintp]]
def setup(self, dtype):
@@ -154,7 +152,7 @@ class PackBits(Benchmark):
np.packbits(self.d2, axis=1)
-class UnpackBits(Benchmark):
+class UnpackBits(object):
def setup(self):
self.d = np.ones(10000, dtype=np.uint8)
self.d2 = np.ones((200, 1000), dtype=np.uint8)
@@ -169,6 +167,6 @@ class UnpackBits(Benchmark):
np.unpackbits(self.d2, axis=1)
-class Indices(Benchmark):
+class Indices(object):
def time_indices(self):
np.indices((1000, 500))
diff --git a/benchmarks/benchmarks/bench_function_base.py b/benchmarks/benchmarks/bench_function_base.py
index a45525793..eea108528 100644
--- a/benchmarks/benchmarks/bench_function_base.py
+++ b/benchmarks/benchmarks/bench_function_base.py
@@ -1,11 +1,9 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
import numpy as np
-class Histogram1D(Benchmark):
+class Histogram1D(object):
def setup(self):
self.d = np.linspace(0, 100, 100000)
@@ -19,7 +17,7 @@ class Histogram1D(Benchmark):
np.histogram(self.d, 10000, (0, 100))
-class Histogram2D(Benchmark):
+class Histogram2D(object):
def setup(self):
self.d = np.linspace(0, 100, 200000).reshape((-1,2))
@@ -33,7 +31,7 @@ class Histogram2D(Benchmark):
np.histogramdd(self.d, (10000, 10000), ((0, 100), (0, 100)))
-class Bincount(Benchmark):
+class Bincount(object):
def setup(self):
self.d = np.arange(80000, dtype=np.intp)
self.e = self.d.astype(np.float64)
@@ -45,7 +43,7 @@ class Bincount(Benchmark):
np.bincount(self.d, weights=self.e)
-class Median(Benchmark):
+class Median(object):
def setup(self):
self.e = np.arange(10000, dtype=np.float32)
self.o = np.arange(10001, dtype=np.float32)
@@ -69,7 +67,7 @@ class Median(Benchmark):
np.median(self.o[:500], overwrite_input=True)
-class Percentile(Benchmark):
+class Percentile(object):
def setup(self):
self.e = np.arange(10000, dtype=np.float32)
self.o = np.arange(10001, dtype=np.float32)
@@ -81,7 +79,7 @@ class Percentile(Benchmark):
np.percentile(self.e, [25, 35, 55, 65, 75])
-class Select(Benchmark):
+class Select(object):
def setup(self):
self.d = np.arange(20000)
self.e = self.d.copy()
@@ -95,7 +93,7 @@ class Select(Benchmark):
np.select(self.cond_large, ([self.d, self.e] * 10))
-class Sort(Benchmark):
+class Sort(object):
def setup(self):
self.e = np.arange(10000, dtype=np.float32)
self.o = np.arange(10001, dtype=np.float32)
@@ -138,7 +136,7 @@ class Sort(Benchmark):
self.o.argsort()
-class Where(Benchmark):
+class Where(object):
def setup(self):
self.d = np.arange(20000)
self.e = self.d.copy()
diff --git a/benchmarks/benchmarks/bench_indexing.py b/benchmarks/benchmarks/bench_indexing.py
index a62a2050e..b058ae597 100644
--- a/benchmarks/benchmarks/bench_indexing.py
+++ b/benchmarks/benchmarks/bench_indexing.py
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark, get_squares_, get_indexes_, get_indexes_rand_
+from .common import get_squares_, get_indexes_, get_indexes_rand_
from os.path import join as pjoin
import shutil
@@ -11,7 +11,7 @@ import numpy as np
from tempfile import mkdtemp
-class Indexing(Benchmark):
+class Indexing(object):
params = [["indexes_", "indexes_rand_"],
['I', ':,I', 'np.ix_(I, I)'],
['', '=1']]
@@ -38,7 +38,7 @@ class Indexing(Benchmark):
self.func()
-class IndexingSeparate(Benchmark):
+class IndexingSeparate(object):
def setup(self):
self.tmp_dir = mkdtemp()
self.fp = memmap(pjoin(self.tmp_dir, 'tmp.dat'),
@@ -58,7 +58,7 @@ class IndexingSeparate(Benchmark):
self.fp[self.indexes]
-class IndexingStructured0D(Benchmark):
+class IndexingStructured0D(object):
def setup(self):
self.dt = np.dtype([('a', 'f4', 256)])
diff --git a/benchmarks/benchmarks/bench_io.py b/benchmarks/benchmarks/bench_io.py
index ce30c4345..1fddfbc8c 100644
--- a/benchmarks/benchmarks/bench_io.py
+++ b/benchmarks/benchmarks/bench_io.py
@@ -1,12 +1,12 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark, get_squares
+from .common import get_squares
import numpy as np
from io import StringIO
-class Copy(Benchmark):
+class Copy(object):
params = ["int8", "int16", "float32", "float64",
"complex64", "complex128"]
param_names = ['type']
@@ -31,7 +31,7 @@ class Copy(Benchmark):
self.dflat[::2] = 2
-class CopyTo(Benchmark):
+class CopyTo(object):
def setup(self):
self.d = np.ones(50000)
self.e = self.d.copy()
@@ -57,14 +57,14 @@ class CopyTo(Benchmark):
np.copyto(self.d, self.e, where=self.im8)
-class Savez(Benchmark):
+class Savez(object):
def setup(self):
self.squares = get_squares()
def time_vb_savez_squares(self):
np.savez('tmp.npz', self.squares)
-class LoadtxtCSVComments(Benchmark):
+class LoadtxtCSVComments(object):
# benchmarks for np.loadtxt comment handling
# when reading in CSV files
@@ -93,7 +93,7 @@ class LoadtxtCSVComments(Benchmark):
delimiter=u',')
self.data_comments.seek(0)
-class LoadtxtCSVdtypes(Benchmark):
+class LoadtxtCSVdtypes(object):
# benchmarks for np.loadtxt operating with
# different dtypes parsed / cast from CSV files
@@ -118,7 +118,7 @@ class LoadtxtCSVdtypes(Benchmark):
dtype=dtype)
self.csv_data.seek(0)
-class LoadtxtCSVStructured(Benchmark):
+class LoadtxtCSVStructured(object):
# benchmarks for np.loadtxt operating with
# a structured data type & CSV file
@@ -141,7 +141,7 @@ class LoadtxtCSVStructured(Benchmark):
self.csv_data.seek(0)
-class LoadtxtCSVSkipRows(Benchmark):
+class LoadtxtCSVSkipRows(object):
# benchmarks for loadtxt row skipping when
# reading in csv file data; a similar benchmark
# is present in the pandas asv suite
@@ -162,7 +162,7 @@ class LoadtxtCSVSkipRows(Benchmark):
delimiter=',',
skiprows=skiprows)
-class LoadtxtReadUint64Integers(Benchmark):
+class LoadtxtReadUint64Integers(object):
# pandas has a similar CSV reading benchmark
# modified to suit np.loadtxt
@@ -188,7 +188,7 @@ class LoadtxtReadUint64Integers(Benchmark):
np.loadtxt(self.data2)
self.data2.seek(0)
-class LoadtxtUseColsCSV(Benchmark):
+class LoadtxtUseColsCSV(object):
# benchmark selective column reading from CSV files
# using np.loadtxt
@@ -208,7 +208,7 @@ class LoadtxtUseColsCSV(Benchmark):
usecols=usecols)
self.csv_data.seek(0)
-class LoadtxtCSVDateTime(Benchmark):
+class LoadtxtCSVDateTime(object):
# benchmarks for np.loadtxt operating with
# datetime data in a CSV file
diff --git a/benchmarks/benchmarks/bench_lib.py b/benchmarks/benchmarks/bench_lib.py
index 83f26c9d1..3a79292da 100644
--- a/benchmarks/benchmarks/bench_lib.py
+++ b/benchmarks/benchmarks/bench_lib.py
@@ -1,15 +1,13 @@
-"""Benchmarks for `numpy.lib`."""
+"""objects for `numpy.lib`."""
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
import numpy as np
-class Pad(Benchmark):
- """Benchmarks for `numpy.pad`."""
+class Pad(object):
+ """objects for `numpy.pad`."""
param_names = ["shape", "pad_width", "mode"]
params = [
diff --git a/benchmarks/benchmarks/bench_linalg.py b/benchmarks/benchmarks/bench_linalg.py
index a65d510be..67d4ce851 100644
--- a/benchmarks/benchmarks/bench_linalg.py
+++ b/benchmarks/benchmarks/bench_linalg.py
@@ -1,11 +1,11 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark, get_squares_, get_indexes_rand, TYPES1
+from .common import get_squares_, get_indexes_rand, TYPES1
import numpy as np
-class Eindot(Benchmark):
+class Eindot(object):
def setup(self):
self.a = np.arange(60000.0).reshape(150, 400)
self.ac = self.a.copy()
@@ -73,7 +73,7 @@ class Eindot(Benchmark):
np.tensordot(self.a3, self.b3, axes=([1, 0], [0, 1]))
-class Linalg(Benchmark):
+class Linalg(object):
params = [['svd', 'pinv', 'det', 'norm'],
TYPES1]
param_names = ['op', 'type']
@@ -100,7 +100,7 @@ class Linalg(Benchmark):
self.func(self.a)
-class Lstsq(Benchmark):
+class Lstsq(object):
def setup(self):
self.a = get_squares_()['float64']
self.b = get_indexes_rand()[:100].astype(np.float64)
diff --git a/benchmarks/benchmarks/bench_ma.py b/benchmarks/benchmarks/bench_ma.py
index d313f01dc..848a0d419 100644
--- a/benchmarks/benchmarks/bench_ma.py
+++ b/benchmarks/benchmarks/bench_ma.py
@@ -1,11 +1,9 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
import numpy as np
-class MA(Benchmark):
+class MA(object):
def setup(self):
self.l100 = range(100)
self.t100 = ([True] * 100)
@@ -20,7 +18,7 @@ class MA(Benchmark):
np.ma.masked_array(self.l100, self.t100)
-class Indexing(Benchmark):
+class Indexing(object):
param_names = ['masked', 'ndim', 'size']
params = [[True, False],
[1, 2],
@@ -47,7 +45,7 @@ class Indexing(Benchmark):
self.m[self.idx_1d]
-class UFunc(Benchmark):
+class UFunc(object):
param_names = ['a_masked', 'b_masked', 'size']
params = [[True, False],
[True, False],
@@ -79,7 +77,7 @@ class UFunc(Benchmark):
np.ma.add(self.a_2d, self.b_2d)
-class Concatenate(Benchmark):
+class Concatenate(object):
param_names = ['mode', 'n']
params = [
['ndarray', 'unmasked',
diff --git a/benchmarks/benchmarks/bench_overrides.py b/benchmarks/benchmarks/bench_overrides.py
index 2cb94c95c..58ba9be04 100644
--- a/benchmarks/benchmarks/bench_overrides.py
+++ b/benchmarks/benchmarks/bench_overrides.py
@@ -1,7 +1,5 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
from numpy.core.overrides import array_function_dispatch
import numpy as np
@@ -32,7 +30,7 @@ class DuckArray(object):
pass
-class ArrayFunction(Benchmark):
+class ArrayFunction(object):
def setup(self):
self.numpy_array = np.array(1)
diff --git a/benchmarks/benchmarks/bench_random.py b/benchmarks/benchmarks/bench_random.py
index 9d84d83d3..240a3cd01 100644
--- a/benchmarks/benchmarks/bench_random.py
+++ b/benchmarks/benchmarks/bench_random.py
@@ -1,11 +1,9 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
import numpy as np
-class Random(Benchmark):
+class Random(object):
params = ['normal', 'uniform', 'weibull 1', 'binomial 10 0.5',
'poisson 10']
@@ -21,7 +19,7 @@ class Random(Benchmark):
self.func(*self.params)
-class Shuffle(Benchmark):
+class Shuffle(object):
def setup(self):
self.a = np.arange(100000)
@@ -29,7 +27,7 @@ class Shuffle(Benchmark):
np.random.shuffle(self.a)
-class Randint(Benchmark):
+class Randint(object):
def time_randint_fast(self):
"""Compare to uint32 below"""
@@ -40,7 +38,7 @@ class Randint(Benchmark):
np.random.randint(0, 2**30 + 1, size=10**5)
-class Randint_dtype(Benchmark):
+class Randint_dtype(object):
high = {
'bool': 1,
'uint8': 2**7,
@@ -66,7 +64,7 @@ class Randint_dtype(Benchmark):
np.random.randint(0, high + 1, size=10**5, dtype=name)
-class Permutation(Benchmark):
+class Permutation(object):
def setup(self):
self.n = 10000
self.a_1d = np.random.random_sample(self.n)
diff --git a/benchmarks/benchmarks/bench_reduce.py b/benchmarks/benchmarks/bench_reduce.py
index 353eb980c..319a4b15f 100644
--- a/benchmarks/benchmarks/bench_reduce.py
+++ b/benchmarks/benchmarks/bench_reduce.py
@@ -1,11 +1,11 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark, TYPES1, get_squares
+from .common import TYPES1, get_squares
import numpy as np
-class AddReduce(Benchmark):
+class AddReduce(object):
def setup(self):
self.squares = get_squares().values()
@@ -16,7 +16,7 @@ class AddReduce(Benchmark):
[np.add.reduce(a, axis=1) for a in self.squares]
-class AddReduceSeparate(Benchmark):
+class AddReduceSeparate(object):
params = [[0, 1], TYPES1]
param_names = ['axis', 'type']
@@ -27,7 +27,7 @@ class AddReduceSeparate(Benchmark):
np.add.reduce(self.a, axis=axis)
-class AnyAll(Benchmark):
+class AnyAll(object):
def setup(self):
self.zeros = np.zeros(100000, bool)
self.ones = np.ones(100000, bool)
@@ -45,7 +45,7 @@ class AnyAll(Benchmark):
self.zeros.any()
-class MinMax(Benchmark):
+class MinMax(object):
params = [np.float32, np.float64, np.intp]
param_names = ['dtype']
@@ -59,7 +59,7 @@ class MinMax(Benchmark):
np.max(self.d)
-class SmallReduction(Benchmark):
+class SmallReduction(object):
def setup(self):
self.d = np.ones(100, dtype=np.float32)
diff --git a/benchmarks/benchmarks/bench_shape_base.py b/benchmarks/benchmarks/bench_shape_base.py
index b05ea8263..ed88aa1fd 100644
--- a/benchmarks/benchmarks/bench_shape_base.py
+++ b/benchmarks/benchmarks/bench_shape_base.py
@@ -1,11 +1,9 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark
-
import numpy as np
-class Block(Benchmark):
+class Block(object):
params = [1, 10, 100]
param_names = ['size']
@@ -65,7 +63,7 @@ class Block(Benchmark):
np.block(np.eye(3 * n))
-class Block3D(Benchmark):
+class Block3D(object):
params = [1, 10, 100]
param_names = ['size']
diff --git a/benchmarks/benchmarks/bench_ufunc.py b/benchmarks/benchmarks/bench_ufunc.py
index a7e385f70..cc9e6e34d 100644
--- a/benchmarks/benchmarks/bench_ufunc.py
+++ b/benchmarks/benchmarks/bench_ufunc.py
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, print_function
-from .common import Benchmark, get_squares_
+from .common import get_squares_
import numpy as np
@@ -27,7 +27,7 @@ for name in dir(np):
print("Missing ufunc %r" % (name,))
-class Broadcast(Benchmark):
+class Broadcast(object):
def setup(self):
self.d = np.ones((50000, 100), dtype=np.float64)
self.e = np.ones((100,), dtype=np.float64)
@@ -36,7 +36,7 @@ class Broadcast(Benchmark):
self.d - self.e
-class UFunc(Benchmark):
+class UFunc(object):
params = [ufuncs]
param_names = ['ufunc']
timeout = 10
@@ -60,7 +60,7 @@ class UFunc(Benchmark):
[self.f(*arg) for arg in self.args]
-class Custom(Benchmark):
+class Custom(object):
def setup(self):
self.b = np.ones(20000, dtype=bool)
@@ -77,7 +77,7 @@ class Custom(Benchmark):
(self.b | self.b)
-class CustomInplace(Benchmark):
+class CustomInplace(object):
def setup(self):
self.c = np.ones(500000, dtype=np.int8)
self.i = np.ones(150000, dtype=np.int32)
@@ -116,7 +116,7 @@ class CustomInplace(Benchmark):
1. + self.d + 1.
-class CustomScalar(Benchmark):
+class CustomScalar(object):
params = [np.float32, np.float64]
param_names = ['dtype']
@@ -136,7 +136,7 @@ class CustomScalar(Benchmark):
(self.d < 1)
-class Scalar(Benchmark):
+class Scalar(object):
def setup(self):
self.x = np.asarray(1.0)
self.y = np.asarray((1.0 + 1j))
@@ -164,7 +164,7 @@ class ArgPack(object):
))
-class ArgParsing(Benchmark):
+class ArgParsing(object):
# In order to benchmark the speed of argument parsing, all but the
# out arguments are chosen such that they have no effect on the
# calculation. In particular, subok=True and where=True are
@@ -189,7 +189,7 @@ class ArgParsing(Benchmark):
np.add(*arg_pack.args, **arg_pack.kwargs)
-class ArgParsingReduce(Benchmark):
+class ArgParsingReduce(object):
# In order to benchmark the speed of argument parsing, all but the
# out arguments are chosen such that they have minimal effect on the
# calculation.
diff --git a/benchmarks/benchmarks/common.py b/benchmarks/benchmarks/common.py
index d720eaaa8..84cb30461 100644
--- a/benchmarks/benchmarks/common.py
+++ b/benchmarks/benchmarks/common.py
@@ -110,7 +110,3 @@ def get_indexes_rand_():
indexes_rand = get_indexes_rand()
indexes_rand_ = indexes_rand[indexes_rand < nxs]
return indexes_rand_
-
-
-class Benchmark(object):
- sample_time = 0.25