This project explores the performance differences between pure JavaScript and C++ Addons (N-API) for CPU-intensive computations. By leveraging C++ modules in Node.js, we can execute tasks at native speed, making Node.js significantly faster for compute-heavy operations.
✔️ C++ Addon using Node.js N-API for enhanced performance
✔️ Performance benchmarking between JavaScript and C++
✔️ Fibonacci sequence computation as a test case
✔️ Ideal for AI, cryptography, real-time applications, and data processing
git clone https://github.com/moses000/nodejs-vs-cpp-performance.git
cd nodejs-vs-cpp-performance
npm install
npm install -g node-gyp
node-gyp configure
node-gyp build
node src/index.js
For fibonacci(40)
, the execution times are:
Implementation | Execution Time |
---|---|
JavaScript (Node.js) | 20-30 seconds |
C++ Addon (Node.js) | ~0.02 seconds |
✅ C++ Addon executes ~1000x faster than pure JavaScript! 🚀
This project is licensed under the MIT License. You are free to use, modify, and distribute the code under the license terms.
We welcome contributions to improve this project!
🔹 Report Issues – Open an issue for bugs, suggestions, or discussions
🔹 Pull Requests – Submit improvements, optimizations, or new benchmarks
- 🔥 GitHub: (https://github.com/moses000)
- 📝 Medium: (https://imoleayomoses.medium.com/)
- 🌎 Blog: (https://imoleayomoses.com/blog)
⭐ If you found this project useful, please star this repository! 🚀🔥