Languages
[Edit]
EN

CPU Benchmark - single core speed test with Fibonacci Sequence in JavaScript

10 points
Created by:
Aleena
694

In this short article, I would like to show Fibonacci Sequence test that is run on a single core. The test source code was converted from C++ to JavaScript - check source article.

Example test.js file:

let tmp, a = 0, b = 1;

console.log('Started!');
  
const t1 = Date.now();

for (let i = 0; i < 10000; ++i) {
  	for (let j = 0; j < 1000000; ++j) {
      	tmp = b;
        b = a + b;
        a = tmp;
    }
}

const t2 = Date.now();
const dt = t2 - t1;

console.log('Finished!');

console.log(`Result: ${b}`);
console.log(`Time: ${0.001 * dt}s`);

Running with Node.js:

node test.js

Example output:

Started!
Finished!
Result: Infinity
Time: 17.531s

Notes: Result: Infinity printing is used only to prevent against automatic optimization.

 

Used Node.js: v14.16.0

Used OS: Windows 10 x64

Used PC:

  • Ryzen 9 5900x
  • DRR 4 (2x 32GB)
  • Samsung SSD M.2 970 EVO (1TB)
  • GeForce GTX 970 (4GB RAM)

Notes:

  • same test for the first run under Node.js v16.13.0 took 18.430s,
  • same test run few times under same Node.js instance returned 6.110s - V8 made some optimisation.

 

See also

  1. CPU Benchmark - Raspberry PI vs Banana PI - single core speed test with Fibonacci Sequence

  2. CPU Benchmark - single core speed test with Fibonacci Sequence in Java

  3. CPU Benchmark - single core speed test with Fibonacci Sequence in AssemblyScript

  4. CPU Benchmark - single core speed test with Fibonacci Sequence in Dart

  5. CPU Benchmark - single core speed test with Fibonacci Sequence in PHP

References

  1. Node.js (nodejs.org) - Homepage
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join