|
2 | 2 |
|
3 | 3 | import numpy as np
|
4 | 4 |
|
5 |
| -avx_ufuncs = ['sin', |
| 5 | +unary_ufuncs = ['sin', |
6 | 6 | 'cos',
|
7 | 7 | 'exp',
|
8 | 8 | 'log',
|
|
20 | 20 | 'isinf',
|
21 | 21 | 'signbit']
|
22 | 22 | stride = [1, 2, 4]
|
| 23 | +stride_out = [1, 2, 4] |
23 | 24 | dtype = ['f', 'd']
|
24 | 25 |
|
25 |
| -class AVX_UFunc(Benchmark): |
26 |
| - params = [avx_ufuncs, stride, dtype] |
27 |
| - param_names = ['avx_based_ufunc', 'stride', 'dtype'] |
| 26 | +class Unary(Benchmark): |
| 27 | + params = [unary_ufuncs, stride, stride_out, dtype] |
| 28 | + param_names = ['ufunc', 'stride_in', 'stride_out', 'dtype'] |
28 | 29 | timeout = 10
|
29 | 30 |
|
30 |
| - def setup(self, ufuncname, stride, dtype): |
| 31 | + def setup(self, ufuncname, stride, stride_out, dtype): |
31 | 32 | np.seterr(all='ignore')
|
32 | 33 | try:
|
33 | 34 | self.f = getattr(np, ufuncname)
|
34 | 35 | except AttributeError:
|
35 | 36 | raise NotImplementedError()
|
36 | 37 | N = 10000
|
37 | 38 | self.arr = np.ones(stride*N, dtype)
|
| 39 | + self.arr_out = np.empty(stride_out*N, dtype) |
38 | 40 |
|
39 |
| - def time_ufunc(self, ufuncname, stride, dtype): |
40 |
| - self.f(self.arr[::stride]) |
| 41 | + def time_ufunc(self, ufuncname, stride, stride_out, dtype): |
| 42 | + self.f(self.arr[::stride], self.arr_out[::stride_out]) |
41 | 43 |
|
42 | 44 | class AVX_UFunc_log(Benchmark):
|
43 | 45 | params = [stride, dtype]
|
|
0 commit comments