Skip to content

Commit 3aeea11

Browse files
committed
Improved metrics benchmark
1 parent 0521a7f commit 3aeea11

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

tests/test_bench_metrics.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,37 @@
44
import pandas as pd
55
import numpy as np
66

7+
import numba
8+
79
import tdamapper.utils.metrics as metrics
810

911

12+
@numba.njit(fastmath=True)
1013
def euclidean_numpy(a, b):
1114
return np.sqrt(np.sum((a - b) ** 2))
1215

1316

17+
@numba.njit(fastmath=True)
1418
def euclidean_numpy_linalg(a, b):
1519
return np.linalg.norm(a - b)
1620

1721

22+
@numba.njit(fastmath=True)
1823
def manhattan_numpy(a, b):
1924
return np.sum(np.abs(a - b))
2025

2126

27+
@numba.njit(fastmath=True)
2228
def manhattan_numpy_linalg(a, b):
2329
return np.linalg.norm(a - b, ord=1)
2430

2531

32+
@numba.njit(fastmath=True)
2633
def chebyshev_numpy(a, b):
2734
return np.max(np.abs(a - b))
2835

2936

37+
@numba.njit(fastmath=True)
3038
def chebyshev_numpy_linalg(a, b):
3139
return np.linalg.norm(a - b, ord=np.inf)
3240

@@ -37,7 +45,8 @@ def eval_dist(X, d):
3745

3846

3947
def run_dist_bench(X, d):
40-
return timeit.timeit(lambda: eval_dist(X, d), number=30)
48+
eval_dist(X, d)
49+
return timeit.timeit(lambda: eval_dist(X, d), number=100)
4150

4251

4352
def run_euclidean_bench(X):

0 commit comments

Comments
 (0)