Skip to content

Commit 8bce9f4

Browse files
committed
Improvements in reduction benchs
1 parent d7b0f21 commit 8bce9f4

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

bench/ndarray/expr-reduction-sum-multi.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,24 @@
2323

2424
t0 = time()
2525
res = blosc2.sum(a + b + c, cparams=cparams)
26-
print(f"Time to evaluate: {(time() - t0) * 1000 :.4f} ms")
26+
t = time() - t0
27+
print(f"Time to evaluate: {t * 1000 :.4f} ms", end=" ")
28+
print(f"Speed (GB/s): {(a.nbytes * 3 / 1e9) / t:.2f}")
2729
print("Result:", res, "Mean:", res / (N * N))
2830

2931
na = a[:]
3032
nb = b[:]
3133
nc = c[:]
3234
#np.testing.assert_allclose(res, np.sum(na + nb + nc))
33-
#
34-
#t0 = time()
35-
#res = ne.evaluate("sum(na)")
36-
#print(f"Time to evaluate with NumExpr: {(time() - t0) * 1000 :.4f} ms")
3735

3836
t0 = time()
3937
res = np.sum(na + nb + nc)
40-
print(f"Time to evaluate with NumPy: {(time() - t0) * 1000 :.4f} ms")
38+
t = time() - t0
39+
print(f"Time to evaluate with NumPy: {t * 1000 :.4f} ms", end=" ")
40+
print(f"Speed (GB/s): {(na.nbytes * 3 / 1e9) / t:.2f}")
41+
42+
t0 = time()
43+
res = ne.evaluate("sum(na)")
44+
t = time() - t0
45+
print(f"Time to evaluate with NumExpr: {t * 1000 :.4f} ms", end=" ")
46+
print(f"Speed (GB/s): {(na.nbytes / 1e9) / t:.2f}")

bench/ndarray/expr-reduction-sum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
t0 = time()
3737
res = np.sum(na)
3838
t = time() - t0
39-
print(f"Time to evaluate with NumPy: {t * 1000 :.4f} ms")
39+
print(f"Time to evaluate with NumPy: {t * 1000 :.4f} ms", end=" ")
4040
print(f"Speed (GB/s): {(na.nbytes / 1e9) / t:.2f}")
4141

4242
t0 = time()
4343
res = ne.evaluate("sum(na)")
4444
t = time() - t0
45-
print(f"Time to evaluate with NumExpr: {t * 1000 :.4f} ms")
45+
print(f"Time to evaluate with NumExpr: {t * 1000 :.4f} ms", end=" ")
4646
print(f"Speed (GB/s): {(na.nbytes / 1e9) / t:.2f}")

0 commit comments

Comments
 (0)