mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02: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)
|
np.random.seed(0)
|
||||||
|
|
||||||
def test_bench_mul(benchmark):
|
length = 1000
|
||||||
length = 1000
|
|
||||||
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
|
||||||
|
|
||||||
def mul(x, y):
|
def mul(x, y):
|
||||||
return 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)
|
benchmark(mul, my_obs, my_obs)
|
||||||
|
|
||||||
|
|
||||||
def test_bench_cmul(benchmark):
|
def test_b_cmul(benchmark):
|
||||||
length = 1000
|
|
||||||
my_obs = pe.CObs(pe.Obs([np.random.rand(length)], ['t1']),
|
my_obs = pe.CObs(pe.Obs([np.random.rand(length)], ['t1']),
|
||||||
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)
|
benchmark(mul, my_obs, my_obs)
|
||||||
|
|
||||||
|
|
||||||
def test_bench_matmul(benchmark):
|
def test_b_matmul(benchmark):
|
||||||
dim = 4
|
dim = 4
|
||||||
my_list = []
|
my_list = []
|
||||||
length = 1000
|
|
||||||
for i in range(dim ** 2):
|
for i in range(dim ** 2):
|
||||||
my_list.append(pe.Obs([np.random.rand(length)], ['t1']))
|
my_list.append(pe.Obs([np.random.rand(length)], ['t1']))
|
||||||
my_array = np.array(my_list).reshape((dim, dim))
|
my_array = np.array(my_list).reshape((dim, dim))
|
||||||
|
|
||||||
benchmark(pe.linalg.matmul, my_array, my_array)
|
benchmark(pe.linalg.matmul, my_array, my_array)
|
||||||
|
|
||||||
|
def test_b_cmatmul(benchmark):
|
||||||
def test_bench_cmatmul(benchmark):
|
|
||||||
dim = 4
|
dim = 4
|
||||||
my_list = []
|
my_list = []
|
||||||
length = 1000
|
|
||||||
for i in range(dim ** 2):
|
for i in range(dim ** 2):
|
||||||
my_list.append(pe.CObs(pe.Obs([np.random.rand(length)], ['t1']),
|
my_list.append(pe.CObs(pe.Obs([np.random.rand(length)], ['t1']),
|
||||||
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)
|
benchmark(pe.linalg.matmul, my_array, my_array)
|
||||||
|
|
||||||
|
|
||||||
def test_bench_gamma_method(benchmark):
|
def test_b_gamma(benchmark):
|
||||||
length = 1000
|
|
||||||
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
||||||
benchmark(my_obs.gamma_method)
|
benchmark(my_obs.gamma_method)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue