Overview

This pages presents the execution time of Koffi calls on three benchmarks, where it is compared to a theoretical ideal FFI implementation (approximated with pre-compiled static Node-API glue code), and other FFI implementations:

Linux x86_64

The results presented below were measured on my x86_64 Linux machine (Intel® Core™ Ultra 9 185H).

atoi results for Linux x86_64

This test is based on atoi, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.

memset results for Linux x86_64

This test is based around repeated calls to the standard C function memset. All implementations pass a Node.js Buffer for the pointer argument.

macOS ARM64

The results presented below were measured on an Apple Mac mini M1 hosted by Scaleway.

atoi results for macOS ARM64

This test is based on atoi, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.

memset results for macOS ARM64

This test is based around repeated calls to the standard C function memset. All implementations pass a Node.js Buffer for the pointer argument.

Windows x86_64

The results presented below were measured on my x86_64 Windows machine (AMD Ryzen™ 5 2600).

atoi results for Windows x86_64

This test is based on atoi, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.

memset results for Windows x86_64

This test is based around repeated calls to the standard C function memset. All implementations pass a Node.js Buffer for the pointer argument.

Running benchmarks

Please note that all benchmark results on this page are made with Clang-built binaries.

cd src/koffi
node ../cnoke/cnoke.js --clang --release

cd benchmark
node ../../cnoke/cnoke.js --clang --release

Once everything is built and ready, run:

node benchmark.js