Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funatsufumiya/bun-c-luajit-bench
bun ffi benchmark (vs c, luajit, node, python)
https://github.com/funatsufumiya/bun-c-luajit-bench
bun luajit nodejs
Last synced: about 1 month ago
JSON representation
bun ffi benchmark (vs c, luajit, node, python)
- Host: GitHub
- URL: https://github.com/funatsufumiya/bun-c-luajit-bench
- Owner: funatsufumiya
- Created: 2024-11-09T05:36:20.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-09T11:46:59.000Z (2 months ago)
- Last Synced: 2024-12-01T01:37:44.413Z (about 1 month ago)
- Topics: bun, luajit, nodejs
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bun-c-luajit-bench
bun ffi benchmark (vs c, luajit, node, python)
based on https://bun.sh/blog/compile-and-run-c-in-js
## Usage
### Bun
```bash
$ bun install
$ bun run bench.js
```### Node.js
```bash
$ yarn install
$ yarn global add node-gyp
$ node-gyp rebuild
$ node bench_napi.cjs
```### C
- note: using google benchmark library. below is example for macos.
```bash
$ brew install google-benchmark
$ clang++ ./bench.cpp -L/opt/homebrew/lib -l benchmark -O3 -I/opt/homebrew/include -o bench
$ ./bench
```### Luajit
```bash
$ clang -shared -fPIC -O3 -o libmyRandom.dylib myRandom.c
# (.dylib should be .so on linux)
$ luajit bench.lua
```### Python
```bash
$ clang -shared -fPIC -O3 -o libmyRandom.dylib myRandom.c
# (.dylib should be .so on linux)
$ python bench.py
```## Result
Tested on M1 Macbook Air.
- C: 7.05 ns /iter
- bun: 12.54 ns /iter
- node: 11.47 ns /iter
- luajit: 16.84 ns /iter
- python: 135.26 ns /iter(Used environment)
- clang: 19.1.2
- bun: 1.1.34
- node: v22.9.0
- node-gyp: v10.2.0
- LuaJIT: 2.1.1710088188
- Python: 3.11.5