-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
simple benchmark for the example add() function
In [1]: import example
In [2]: %timeit example.add(1000, 2000)
606 ns ± 33.5 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)release buidl (using cmake -DCMAKE_BUILD_TYPE=Release .. ) improves the speed:
In [1]: import example
In [2]: %timeit example.add(1000, 2000)
469 ns ± 16.8 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)however, comparing with cython it still not fast enough:
In [10]: %reload_ext cython
In [11]:
...: %%cython
...: cpdef int cython_add(int a, int b):
...: return a + b
...:
In [12]: %timeit cython_add(1000, 2000)
114 ns ± 5.48 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)pybind11 is 4X times slower than cython.
Why that happened? Is there anything to do to improve the performance here?
schneiderfelipeschneiderfelipe
Metadata
Metadata
Assignees
Labels
No labels