dyu/ffi-overhead logo

dyu/ffi-overhead

Free

comparing the c ffi (foreign function interface) overhead on various programming languages

FreeFree tier
Type
Open Source

About dyu/ffi-overhead

This open-source project benchmarks the foreign function interface (FFI) overhead of calling a simple C function (plusone) from multiple programming languages. It provides a reproducible methodology with compile and run scripts, and presents raw elapsed time results for 500 million calls. Languages tested include C, C++, Rust, Go, Java, LuaJIT, Julia, Nim, V, D, Haskell, OCaml, C#, Node.js, Dart, Wren, and Elixir. The project is licensed under Apache 2.0 and was originally run on an Intel i7-3630QM laptop with Ubuntu 14.04.

Key Features

Compares FFI overhead across 18+ programming languages
Simple benchmark: calls a C 'plusone' function repeatedly
Reproducible methodology with compile and run scripts (compile-all.sh, run-all.sh)
Provides raw elapsed time results for two samples (500 million calls each)
Open-source under Apache 2.0 license
Supports static and dynamic languages (C, Rust, Go, Java, LuaJIT, Julia, Nim, V, D, Haskell, OCaml, C#, Node.js, Dart, Wren, Elixir)

Pros & Cons

Pros
  • Comprehensive comparison of many languages in a single benchmark
  • Transparent methodology with scripts to reproduce results
  • Results from a documented environment (CPU, OS, compiler versions)
  • Open-source and free to use
  • Simple benchmark easy to understand and replicate
Cons
  • Benchmark only measures one simple function call (plusone)
  • Environment may be outdated (Ubuntu 14.04, older compiler versions from 2017)
  • Results may not generalize to real-world FFI usage
  • No continuous integration or updates since initial publication
  • Only tested on Linux x86_64

Best For

Evaluating FFI performance for language selectionIdentifying low-overhead FFI for systems programmingResearch on cross-language interoperability overheadPerformance tuning of multi-language applications

FAQ

What does this benchmark measure?
It measures the elapsed time in milliseconds to call a simple C function 'plusone' (int plusone(int x)) repeatedly 500 million times from various languages.
Which languages are included?
The benchmark includes C, C++, Rust, Go, Java, LuaJIT, Julia, Nim, V, D, Haskell, OCaml, C#, Node.js, Dart, Wren, Elixir, and others.
What is the license?
The project is licensed under Apache 2.0.
How can I reproduce the results?
The repository includes shell scripts compile-all.sh and run-all.sh, and requires dependencies listed in the README. Run 'tup init' then './compile-all.sh' and './run-all.sh 500000000'.
What environment was used?
Intel i7-3630QM laptop, Ubuntu 14.04 x64, with various compilers and runtimes (e.g., gcc 5.4.1, rust 1.17.0, java 1.8.0, etc.).