mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
benchmarks simplified
This commit is contained in:
parent
f38f86ae32
commit
7874bdb1fd
1 changed files with 11 additions and 17 deletions
|
@ -5,42 +5,37 @@ import time
|
|||
|
||||
np.random.seed(0)
|
||||
|
||||
def test_bench_mul(benchmark):
|
||||
length = 1000
|
||||
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
||||
length = 1000
|
||||
|
||||
def mul(x, y):
|
||||
return x * y
|
||||
def mul(x, y):
|
||||
return x * y
|
||||
|
||||
|
||||
def test_b_mul(benchmark):
|
||||
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
||||
|
||||
benchmark(mul, my_obs, my_obs)
|
||||
|
||||
|
||||
def test_bench_cmul(benchmark):
|
||||
length = 1000
|
||||
def test_b_cmul(benchmark):
|
||||
my_obs = pe.CObs(pe.Obs([np.random.rand(length)], ['t1']),
|
||||
pe.Obs([np.random.rand(length)], ['t1']))
|
||||
|
||||
def mul(x, y):
|
||||
return x * y
|
||||
|
||||
benchmark(mul, my_obs, my_obs)
|
||||
|
||||
|
||||
def test_bench_matmul(benchmark):
|
||||
def test_b_matmul(benchmark):
|
||||
dim = 4
|
||||
my_list = []
|
||||
length = 1000
|
||||
for i in range(dim ** 2):
|
||||
my_list.append(pe.Obs([np.random.rand(length)], ['t1']))
|
||||
my_array = np.array(my_list).reshape((dim, dim))
|
||||
|
||||
benchmark(pe.linalg.matmul, my_array, my_array)
|
||||
|
||||
|
||||
def test_bench_cmatmul(benchmark):
|
||||
def test_b_cmatmul(benchmark):
|
||||
dim = 4
|
||||
my_list = []
|
||||
length = 1000
|
||||
for i in range(dim ** 2):
|
||||
my_list.append(pe.CObs(pe.Obs([np.random.rand(length)], ['t1']),
|
||||
pe.Obs([np.random.rand(length)], ['t1'])))
|
||||
|
@ -49,7 +44,6 @@ def test_bench_cmatmul(benchmark):
|
|||
benchmark(pe.linalg.matmul, my_array, my_array)
|
||||
|
||||
|
||||
def test_bench_gamma_method(benchmark):
|
||||
length = 1000
|
||||
def test_b_gamma(benchmark):
|
||||
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
||||
benchmark(my_obs.gamma_method)
|
||||
|
|
Loading…
Add table
Reference in a new issue