mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
Benchmarks added
This commit is contained in:
parent
8655fe2cd1
commit
b5f3dd6ac3
9 changed files with 58 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
name: CI
|
||||
name: pytest
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -30,6 +30,7 @@ jobs:
|
|||
pip install .
|
||||
pip install pytest
|
||||
pip install pytest-cov
|
||||
pip install pytest-benchmark
|
||||
|
||||
- name: Run tests
|
||||
run: pytest --cov=pyerrors -v
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@ __pycache__
|
|||
*.pyc
|
||||
.ipynb_*
|
||||
.coverage
|
||||
.benchmarks
|
||||
.cache
|
||||
examples/B1k2_pcac_plateau.p
|
||||
examples/Untitled.*
|
||||
|
|
55
tests/benchmark_test.py
Normal file
55
tests/benchmark_test.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
import numpy as np
|
||||
import pyerrors as pe
|
||||
import pytest
|
||||
import time
|
||||
|
||||
np.random.seed(0)
|
||||
|
||||
def test_bench_mul(benchmark):
|
||||
length = 1000
|
||||
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
||||
|
||||
def mul(x, y):
|
||||
return x * y
|
||||
|
||||
benchmark(mul, my_obs, my_obs)
|
||||
|
||||
|
||||
def test_bench_cmul(benchmark):
|
||||
length = 1000
|
||||
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):
|
||||
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):
|
||||
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'])))
|
||||
my_array = np.array(my_list).reshape((dim, dim))
|
||||
|
||||
benchmark(pe.linalg.matmul, my_array, my_array)
|
||||
|
||||
|
||||
def test_bench_gamma_method(benchmark):
|
||||
length = 1000
|
||||
my_obs = pe.Obs([np.random.rand(length)], ['t1'])
|
||||
benchmark(my_obs.gamma_method)
|
Loading…
Add table
Reference in a new issue