From 0b3366f3c1860e0fd5f34be995024c6765d26dbe Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Thu, 18 Oct 2018 19:10:24 +0200 Subject: [PATCH] bench: add benchmark of switch between np.array and np.matrix --- benchmarks/bench-switch.py | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 benchmarks/bench-switch.py diff --git a/benchmarks/bench-switch.py b/benchmarks/bench-switch.py new file mode 100644 index 00000000..5aa6d1d2 --- /dev/null +++ b/benchmarks/bench-switch.py @@ -0,0 +1,46 @@ +from __future__ import print_function + +import eigenpy +import numpy as np + +import time +import timeit + +from IPython import get_ipython +ipython = get_ipython() + +quat = eigenpy.Quaternion() +a = [0., 0., 0.] + +cmd1 = "timeit np.array(a)" +print("\n") +print(cmd1) +ipython.magic(cmd1) +print("\n") + +cmd2 = "timeit np.matrix(a)" +print(cmd2) +ipython.magic(cmd2) +print("\n") + +eigenpy.switchToNumpyMatrix() +print("----------------------") +print("switch to numpy matrix") +print("----------------------") +print("\n") + +cmd3 = "timeit quat.coeffs()" +print(cmd3) +ipython.magic(cmd3) +print("\n") + +eigenpy.switchToNumpyArray() +print("---------------------") +print("switch to numpy array") +print("---------------------") +print("\n") + +cmd4 = "timeit quat.coeffs()" +print(cmd4) +ipython.magic(cmd4) +print("\n") -- GitLab