Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dyu/ffi-overhead
comparing the c ffi (foreign function interface) overhead on various programming languages
https://github.com/dyu/ffi-overhead
benchmark c ffi
Last synced: 4 days ago
JSON representation
comparing the c ffi (foreign function interface) overhead on various programming languages
- Host: GitHub
- URL: https://github.com/dyu/ffi-overhead
- Owner: dyu
- License: apache-2.0
- Created: 2013-09-23T13:40:03.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T14:43:22.000Z (over 1 year ago)
- Last Synced: 2024-10-14T00:08:23.092Z (3 months ago)
- Topics: benchmark, c, ffi
- Language: C
- Homepage:
- Size: 88.9 KB
- Stars: 657
- Watchers: 28
- Forks: 40
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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
- elixirMy 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
```sh
tup init
```### Compile
```sh
./compile-all.sh
```Compile opts:
- -O2 (gcc - applies to c/jni/nim)
- -C opt-level=2 (rust)### Run
```sh
./run-all.sh 1000000
```Measurement:
- call the c function "plusone" x number of times and print out the elapsed time in millis.
```c
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
905julia:
894
889c:
1182
1182cpp:
1182
1183zig:
1191
1190nim:
1330
1330v:
1779
1781rust:
1193
1196d:
1330
1330d ldc2:
1191
1189haskell:
1197
1198ocamlopt:
1634
1634ocamlc:
4299
4302csharp mono:
2697
2690java7:
4469
4472java8:
4505
4472node:
9163
9194node scoped:
15425
15409go:
37975
37879dart:
31265
31282dart scoped:
61906
69043wren:
14519
14514elixir:
23852
23752
```