8000 added timing for different norm options · zfxu/spatialmath-python@2a1d74d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a1d74d

Browse files
committed
added timing for different norm options
1 parent 0fa7e13 commit 2a1d74d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spatialmath/timing.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def result(op, t):
217217
from spatialmath import base
218218
import numpy as np
219219
s = np.r_[1.0,2,3,4,5,6]
220+
s3 = np.r_[1.0,2,3]
220221
a = np.r_[1.0, 2.0, 3.0]
221222
b = np.r_[-5.0, 4.0, 3.0]
222223
@@ -244,4 +245,15 @@ def result(op, t):
244245
t = timeit.timeit(stmt='a = np.sum(s ** 2)', setup=misc_setup, number=N)
245246
result("np.sum(s ** 2)", t)
246247

248+
t = timeit.timeit(stmt='a = np.linalg.norm(s)', setup=misc_setup, number=N)
249+
result("np.norm(R6)", t)
250+
t = timeit.timeit(stmt='a = base.norm(s)', setup=misc_setup, number=N)
251+
result("base.norm(R6)", t)
252+
253+
t = timeit.timeit(stmt='a = np.linalg.norm(s3)', setup=misc_setup, number=N)
254+
result("np.norm(R3)", t)
255+
t = timeit.timeit(stmt='a = base.norm(s3)', setup=misc_setup, number=N)
256+
result("base.norm(R3)", t)
257+
258+
247259
table.print()

0 commit comments

Comments
 (0)
0