Skip to content

Commit

Permalink
CLN: remove the internal Benchmark class
Browse files Browse the repository at this point in the history
  • Loading branch information
shoyer committed Sep 24, 2018
1 parent 0da1b95 commit 1846ac3
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 86 deletions.
6 changes: 2 additions & 4 deletions benchmarks/benchmarks/bench_app.py
Original file line number Diff line number Diff line change
@@ -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']

Expand Down Expand Up @@ -53,7 +51,7 @@ def time_it(self, update):
self.run()


class MaxesOfDots(Benchmark):
class MaxesOfDots(object):
def setup(self):
np.random.seed(1)
nsubj = 5
Expand Down
16 changes: 7 additions & 9 deletions benchmarks/benchmarks/bench_core.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -76,7 +74,7 @@ def time_tril_l10x10(self):
np.tril(self.l10x10)


class Temporaries(Benchmark):
class Temporaries(object):
def setup(self):
self.amid = np.ones(50000)
self.bmid = np.ones(50000)
Expand All @@ -96,7 +94,7 @@ def time_large2(self):
(self.alarge + self.blarge) - 2


class CorrConv(Benchmark):
class CorrConv(object):
params = [[50, 1000, 1e5],
[10, 100, 1000, 1e4],
['valid', 'same', 'full']]
Expand All @@ -113,7 +111,7 @@ def time_convolve(self, size1, size2, mode):
np.convolve(self.x1, self.x2, mode=mode)


class CountNonzero(Benchmark):
class CountNonzero(object):
param_names = ['numaxes', 'size', 'dtype']
params = [
[1, 2, 3],
Expand All @@ -137,7 +135,7 @@ def time_count_nonzero_multi_axis(self, numaxes, size, dtype):
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):
Expand All @@ -154,7 +152,7 @@ def time_packbits_axis1(self, dtype):
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)
Expand All @@ -169,6 +167,6 @@ def time_unpackbits_axis1(self):
np.unpackbits(self.d2, axis=1)


class Indices(Benchmark):
class Indices(object):
def time_indices(self):
np.indices((1000, 500))
18 changes: 8 additions & 10 deletions benchmarks/benchmarks/bench_function_base.py
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -19,7 +17,7 @@ def time_fine_binning(self):
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))

Expand All @@ -33,7 +31,7 @@ def time_fine_binning(self):
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)
Expand All @@ -45,7 +43,7 @@ def time_weights(self):
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)
Expand All @@ -69,7 +67,7 @@ def time_odd_small(self):
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)
Expand All @@ -81,7 +79,7 @@ def time_percentile(self):
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()
Expand All @@ -95,7 +93,7 @@ def time_select_larger(self):
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)
Expand Down Expand Up @@ -138,7 +136,7 @@ def time_argsort_random(self):
self.o.argsort()


class Where(Benchmark):
class Where(object):
def setup(self):
self.d = np.arange(20000)
self.e = self.d.copy()
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/benchmarks/bench_indexing.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +11,7 @@
from tempfile import mkdtemp


class Indexing(Benchmark):
class Indexing(object):
params = [["indexes_", "indexes_rand_"],
['I', ':,I', 'np.ix_(I, I)'],
['', '=1']]
Expand All @@ -38,7 +38,7 @@ def time_op(self, indexes, sel, op):
self.func()


class IndexingSeparate(Benchmark):
class IndexingSeparate(object):
def setup(self):
self.tmp_dir = mkdtemp()
self.fp = memmap(pjoin(self.tmp_dir, 'tmp.dat'),
Expand All @@ -58,7 +58,7 @@ def time_mmap_fancy_indexing(self):
self.fp[self.indexes]


class IndexingStructured0D(Benchmark):
class IndexingStructured0D(object):
def setup(self):
self.dt = np.dtype([('a', 'f4', 256)])

Expand Down
22 changes: 11 additions & 11 deletions benchmarks/benchmarks/bench_io.py
Original file line number Diff line number Diff line change
@@ -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']
Expand All @@ -31,7 +31,7 @@ def time_strided_assign(self, typename):
self.dflat[::2] = 2


class CopyTo(Benchmark):
class CopyTo(object):
def setup(self):
self.d = np.ones(50000)
self.e = self.d.copy()
Expand All @@ -57,14 +57,14 @@ def time_copyto_8_dense(self):
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

Expand Down Expand Up @@ -93,7 +93,7 @@ def time_comment_loadtxt_csv(self, num_lines):
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

Expand All @@ -118,7 +118,7 @@ def time_loadtxt_dtypes_csv(self, dtype, num_lines):
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

Expand All @@ -141,7 +141,7 @@ def time_loadtxt_csv_struct_dtype(self):
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
Expand All @@ -162,7 +162,7 @@ def time_skiprows_csv(self, skiprows):
delimiter=',',
skiprows=skiprows)

class LoadtxtReadUint64Integers(Benchmark):
class LoadtxtReadUint64Integers(object):
# pandas has a similar CSV reading benchmark
# modified to suit np.loadtxt

Expand All @@ -188,7 +188,7 @@ def time_read_uint64_neg_values(self, size):
np.loadtxt(self.data2)
self.data2.seek(0)

class LoadtxtUseColsCSV(Benchmark):
class LoadtxtUseColsCSV(object):
# benchmark selective column reading from CSV files
# using np.loadtxt

Expand All @@ -208,7 +208,7 @@ def time_loadtxt_usecols_csv(self, usecols):
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

Expand Down
8 changes: 3 additions & 5 deletions benchmarks/benchmarks/bench_lib.py
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/benchmarks/bench_linalg.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -73,7 +73,7 @@ def time_tensordot_a_b_axes_1_0_0_1(self):
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']
Expand All @@ -100,7 +100,7 @@ def time_op(self, op, typename):
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)
Expand Down
10 changes: 4 additions & 6 deletions benchmarks/benchmarks/bench_ma.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -20,7 +18,7 @@ def time_masked_array_l100_t100(self):
np.ma.masked_array(self.l100, self.t100)


class Indexing(Benchmark):
class Indexing(object):
param_names = ['masked', 'ndim', 'size']
params = [[True, False],
[1, 2],
Expand All @@ -47,7 +45,7 @@ def time_1d(self, masked, ndim, size):
self.m[self.idx_1d]


class UFunc(Benchmark):
class UFunc(object):
param_names = ['a_masked', 'b_masked', 'size']
params = [[True, False],
[True, False],
Expand Down Expand Up @@ -79,7 +77,7 @@ def time_2d(self, a_masked, b_masked, size):
np.ma.add(self.a_2d, self.b_2d)


class Concatenate(Benchmark):
class Concatenate(object):
param_names = ['mode', 'n']
params = [
['ndarray', 'unmasked',
Expand Down
Loading

0 comments on commit 1846ac3

Please sign in to comment.