GitXplorerGitXplorer
f

javascript-vs-native-addon-prime-numbers

public
27 stars
12 forks
0 issues

Commits

List of commits on branch master.
Unverified
d1252e6af5ab7a84151e45ad9d76206aafe9c077

README: Complete setup instructions

mmathiasbynens committed 7 years ago
Unverified
cc526e4276ebf2f7ad2fd5568fc8ab8770db5035

Use C++ wrapper module

ffhinkel committed 7 years ago
Unverified
44aefa5911d45f35e747e3a824d19458ca813885

Update Readme

ffhinkel committed 7 years ago
Unverified
bed769a707ac4d52a081271ee9ef54c23b4701ad

Create LICENSE

ffhinkel committed 7 years ago
Unverified
857f1057bc7bccd7b041fdcc4dab002df0eab3c1

Implement prime number algorithms in C++ and JavaScript

ffhinkel committed 7 years ago
Unverified
0d8af0b9cf914259dc543d7a466f6d6c4d289b63

Initial import

ffhinkel committed 7 years ago

README

The README file for this repository.

Speed up your Node.js App with Native Addons. What’s faster, C++ or JavaScript?

This example compares JavaScript to C++ in Node.js for computing prime numbers.

JavaScript is a ridiculously fast scripting language thanks to modern JavaScript engines. But how fast is JavaScript compared to C++? This repository contains an example that computes prime numbers in Node both with JavaScript and with a native C++ addon.

Usage

git clone git@github.com:fhinkel/javascript-vs-native-addon-prime-numbers.git
cd javascript-vs-native-addon-prime-numbers
npm install
npm start

Experiment with this example yourself. Just remember to run npm install to recompile the addon if you change any C++ code.

Results

If your Node app’s sole purpose is to compute prime numbers and you don’t want to use a fast lookup table, please rely on this benchmark 100%. For anything else, this benchmark is probably useless.

The JavaScript and the C++ implementation use the same algorithm. Calling into the addon and running the computations in C++ is faster than staying in JavaScript except for small prime numbers, i.e., the first 25 prime numbers.

Computing the first 1,000,000 prime numbers without warm up

Computing the first 1,000,000 prime numbers with Node 9.2.

Computing prime numbers without adaptive optimizations

Computing prime numbers without adaptive optimizations.

License

MIT