Skip to content

Instantly share code, notes, and snippets.

@diyan
Last active January 3, 2016 10:19
Show Gist options
  • Save diyan/8448203 to your computer and use it in GitHub Desktop.
Save diyan/8448203 to your computer and use it in GitHub Desktop.
C wrappers benchmark result on Asus Zenbook Prime UX31A / Core i7 3517U 1900 Mhz / Ubuntu 13.10 64 bit / Python 2.7.5 64 bit

Python C wrappers benchmark result on Asus Zenbook Prime UX31A / Core i7 3517U 1900 Mhz / Ubuntu 13.10 64 bit / Python 2.7.5 64 bit

Installation instructions for Ubuntu 13.10

$ git clone https://github.com/koder-ua/wrappers_test.git && cd $_
$ virtualenv . && . bin/activate
$ sudo apt-get install python-dev swig python-sip-dev libffi-dev libboost-python-dev python-sip-dev
$ pip install cython cffi
$ make

Actual results:

ctypes :
    empty  : 146  ns
    simple : 208  ns
    many   : 1.01 us
    struct : 398  ns
swig :
    empty  : 46.4 ns
    simple : 87.1 ns
    many   : 204  ns
    struct : 166  ns
cython :
    empty  : 28.9 ns
    simple : 50.5 ns
    many   : 139  ns
    struct : 430  ns
cffi :
    empty  : 74.3 ns
    simple : 125  ns
    many   : 270  ns
    struct : 129  ns
boost_python :
    empty  : 87.5 ns
    simple : 151  ns
    many   : 457  ns
    struct : 233  ns

Unfortunately sip benchmark failed to run on my workstation:

$ python test.py sip
sip :
    empty  :
Traceback (most recent call last):
  File "test.py", line 54, in <module>
    print "    empty  :", num_to_user(tt("func()", stmt.format("empty_func")))
  File "test.py", line 30, in tt
    res = timeit.timeit(exec_stmt, setup_stmt, number=number)
  File "/usr/lib/python2.7/timeit.py", line 230, in timeit
    return Timer(stmt, setup, timer).timeit(number)
  File "/usr/lib/python2.7/timeit.py", line 195, in timeit
    timing = self.inner(it, self.timer)
  File "<timeit-src>", line 4, in inner
  File "sip/wtest.py", line 1, in <module>
    import _wtest
ImportError: sip/_wtest.so: undefined symbol: sipTypeDef__wtest_Data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment