GithubHelp home page GithubHelp logo

unicodex / pcpc Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 1.76 MB

Python CFFI Performance Comparison

Shell 0.05% Nim 12.66% Python 55.31% C 31.79% V 0.18%
python python3 cffi python-library python-lib comparison performance performance-analysis performance-metrics performance-testing

pcpc's Introduction

PCPC (Python CFFI Performance Comparison)

The purpose of this repo is to compare different options for creating Python modules and their efficiency, relative to each-other.

TODOs

  • Add more benchmarks

How Libraries Were Built

  • Nuitka -- nuitka3 --lto --module /path/to/lib.py
  • Cython -- cythonize -a -i /path/to/lib.pyx
  • Nim -- nim c --app:lib -d:release --gc:markAndSweep --out:lib.[so|pyd] /path/to/lib.nim
  • V -- v -shared -prod /path/to/lib.v

Current Benchmark Output

$ ./benchmark_all.sh 

Running benchmark 'base64'
---------------------------------------------------------
Python : 0.1405s                                    1.00x
Nuitka : 0.1410s                                    1.00x
Cython : 0.1441s                                    0.97x
Nim    : 0.0845s                                    1.66x

Running benchmark 'fibonacci_iterative' to 100000 places.
---------------------------------------------------------
Python : 1.1194s                                    1.00x
Nuitka : 1.1471s                                    0.98x
Cython : 0.0007s                                1,559.35x
Numba  : 0.0004s                                2,980.38x
Nim    : 0.0007s                                1,499.98x
V      : 0.0029s                                  383.67x

Running benchmark 'fibonacci_recursive' to 30 places.
---------------------------------------------------------
Python : 1.6359s                                    1.00x
Nuitka : 1.0064s                                    1.63x
Cython : 0.3227s                                    5.07x
Numba  : 0.0582s                                   28.13x
Nim    : 0.0182s                                   89.79x
V      : 0.0585s                                   27.97x

Running benchmark 'json_loads'.
_NOTE:_ JSON parsing within Nim is quite fast. I believe
there is extra overhead from converting each value to a
string. There is probably also more efficient way to do 
pass this data back to Python. Suggestions welcome.
---------------------------------------------------------
Python : 0.1633s                                    1.00x
Nuitka : 0.1583s                                    1.03x
Cython : 0.1573s                                    1.04x
Numba  : 0.5923s                                    0.28x
Nim    : 0.5128s                                    0.32x

Running benchmark 'gen_range'.
---------------------------------------------------------
Python : 0.4937s                                    1.00x
Nuitka : 0.4567s                                    1.08x
Cython : 0.1428s                                    3.46x
Numba  : 0.3121s                                    1.58x
Nim    : 0.3362s                                    1.47x

Benchmarks were ran in a VM with the following specs.

 OS: Antergos 
 Kernel: x86_64 Linux 
 Packages: 908
 Shell: zsh 5.7.1
 CPU: Intel Core i7-6700 
 GPU: vboxdrmfb
 RAM: 1115MiB / 3000MiB

Suggestions

Suggestions for more benchmarks are welcome, as well as PRs.

pcpc's People

Contributors

unicodex avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.