https://github.com/dyu/ffi-overhead Skip to content Sign up * Product + Features + Mobile + Actions + Codespaces + Packages + Security + Code review + Issues + Integrations + GitHub Sponsors + Customer stories * Team * Enterprise * Explore + Explore GitHub + Learn and contribute + Topics + Collections + Trending + Learning Lab + Open source guides + Connect with others + The ReadME Project + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing + Plans + Compare plans + Contact Sales + Education [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} dyu / ffi-overhead Public * Notifications * Fork 36 * Star 526 comparing the c ffi (foreign function interface) overhead on various programming languages License Apache-2.0 license 526 stars 36 forks Star Notifications * Code * Issues 8 * Pull requests 7 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 3 branches 0 tags Code Latest commit @dyu dyu add v ... c0f176f Apr 29, 2021 add v c0f176f Git stats * 103 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time dart dart scoped Feb 23, 2017 elixir refactor elixir May 31, 2018 jhello docs: fix simple typo, caculate -> calculate Dec 19, 2020 newplus docs: fix simple typo, caculate -> calculate Dec 19, 2020 node node scoped Feb 23, 2017 ocaml use untagged int by default May 31, 2018 wren wren Mar 14, 2018 .gitignore ignore ocaml files May 31, 2018 LICENSE Initial commit Sep 23, 2013 README.md add v Apr 29, 2021 Tupfile add v Apr 29, 2021 Tuprules.tup uniform flags Feb 24, 2017 build.zig add zig Mar 28, 2018 compile-all.sh chain May 31, 2018 hello.c iteration count via cli args Feb 23, 2017 hello.cpp iteration count via cli args Feb 23, 2017 hello.cs C# with Mono May 27, 2018 hello.d dlang betterC Jan 5, 2018 hello.dart iteration count via cli args Feb 23, 2017 hello.ex refactor elixir May 31, 2018 hello.go iteration count via cli args Feb 23, 2017 hello.hs Move increment out of IO Jul 21, 2018 hello.jl add julia to the run script May 27, 2018 hello.js iteration count via cli args Feb 23, 2017 hello.lua iteration count via cli args Feb 23, 2017 hello.nim Mirror C compatibility types from Rust in Nim May 27, 2018 hello.rs iteration count via cli args Feb 23, 2017 hello.v add v Apr 29, 2021 hello.wren 1st arg as script Feb 13, 2018 hello.zig elapsed Mar 28, 2018 prev.md prev Feb 17, 2017 run-all.sh add v Apr 29, 2021 View code ffi-overhead Initialize Compile Run Results (500M calls) README.md ffi-overhead comparing the c ffi overhead on various programming languages Requirements: * gcc * tup * zig * nim * v * java7 * java8 * go * rust * d (dmd and ldc2) * haskell (ghc) * ocaml * csharp (mono) * luajit * julia * node * dart * wren * elixir My environment: - Intel i7-3630QM laptop (4cores, HT) with 16g ram - Ubuntu 14.04 x64 - gcc/g++ 5.4.1 - tup 0.7.4 - zig 0.2.0 - nim 0.14.3 - v 0.2.2 aebb551 - java 1.7.0_72 and 1.8.0_91 - go 1.8.0 - rust 1.17.0-nightly (c0b7112ba 2017-03-02) - dmd 2.0.71.1 - ldc2 1.9.0 - ghc 7.10.3 (at /opt/ghc) - ocaml 4.06.1 - mono 5.12.0.226 # dynamic languages - luajit 2.0.4 - julia 0.6.3 - node 6.9.0 (at /opt/node) - dart 1.22.0 (at /usr/lib/dart) - wren 0.1.0 - elixir 1.6.5 (Erlang/OTP 20) Initialize tup init Compile ./compile-all.sh Compile opts: * -O2 (gcc - applies to c/jni/nim) * -C opt-level=2 (rust) Run ./run-all.sh 1000000 Measurement: * call the c function "plusone" x number of times and print out the elapsed time in millis. int x = 0; while (x < count) x = plusone(x); * 2 samples/runs Results (500M calls) ./run-all.sh 500000000 The results are elapsed time in milliseconds ============================================ luajit: 891 905 julia: 894 889 c: 1182 1182 cpp: 1182 1183 zig: 1191 1190 nim: 1330 1330 v: 1779 1781 rust: 1193 1196 d: 1330 1330 d ldc2: 1191 1189 haskell: 1197 1198 ocamlopt: 1634 1634 ocamlc: 4299 4302 csharp mono: 2697 2690 java7: 4469 4472 java8: 4505 4472 node: 9163 9194 node scoped: 15425 15409 go: 37975 37879 dart: 31265 31282 dart scoped: 61906 69043 wren: 14519 14514 elixir: 23852 23752 About comparing the c ffi (foreign function interface) overhead on various programming languages Topics c benchmark ffi Resources Readme License Apache-2.0 license Stars 526 stars Watchers 24 watching Forks 36 forks Releases No releases published Packages 0 No packages published Contributors 10 * @dyu * @puffnfresh * @dextorious * @minond * @let-def * @slofurno * @NattyNarwhal * @sirlensalot * @metagn * @timgates42 Languages * C 52.7% * C++ 9.0% * OCaml 6.9% * Shell 4.3% * Zig 3.5% * Java 2.8% * Other 20.8% * (c) 2022 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.