On Github luismreis / hardcore-v8
Lets get serious!
build/gyp_v8 make release
build/gyp_v8 make arm.release armv7=false vfp3=off hardfp=on\ disassembler=on console=readline gdbjit=on\ library=shared
PREFIX=$HOME/opt/node ./configure\ --prefix=$PREFIX make install
PREFIX=$HOME/opt/node ./configure\ --shared-v8\ --shared-v8-includes=$HOME/opt/v8/include\ --shared-v8-libpath=$HOME/opt/v8/lib\ --prefix=$PREFIX make install
node --v8-options
node --prof --noprof-lazy
require('heapdump'); fs.readdirSync('.').map(function (filename) { if (filename.match(/^heapdump-/)) { console.log(filename); fs.unlinkSync(filename); } }); setInterval(function heapDumper() { process.kill(process.pid, 'SIGUSR2'); }, 15000);
var LIMIT = 1000000; function Spinner() { var buffer = new Array(LIMIT); var i = 0; setInterval(function () { buffer[i] = Date.now() * (1 + Math.sqrt(5)) / 2; i = (i + 1) % LIMIT; }, 200); } var i = 0; var mouseClick = function () { new Spinner(); if (i++ < 100) { setTimeout(mouseClick, 200); } } mouseClick();
node --prof --noprof-lazy my-script.js
Analyzing
mac-tick-processor v8.log > v8.log.processed
Project Euler 1st Problem
function multiplesOf3and5() { var result = [], sum = 0; for (var i = 0; i < 1000 * 1000; i++) { if (i % 3 === 0 || i % 5 === 0) { sum += i; result.push(i); } } return [result, result.length, sum]; } for (var i = 100; i > 0; i--) { var res = multiplesOf3and5(); if (i === 1) { print('length: ' + res[1] + ' - sum: ' + res[2]); } }
Project Euler 1st Problem
function multiplesOf3and5() { var result = [], j = 0, sum = 0; for (var i=0; i < 1000 * 1000; i++) { if (i % 3 === 0 || i % 5 === 0) { if (j == result.length) { result.length += 1000; } sum += i; result[j++] = i; } } return [result, j, sum]; } for (var i = 100; i > 0; i--) { var res = multiplesOf3and5(); if (i === 1) { print('length: ' + res[1] + ' - sum: ' + res[2]); } }
Project Euler 1st Problem
var result = new Array(1000), size, sum; function multiplesOf3and5() { size = 0; for (var i = 0; i < 1000 * 1000; i++) { if (i % 3 === 0 || i % 5 === 0) { if (size === result.length) { result.length += 1000; } sum += i; result[size++] = i; } } } for (var i = 100; i > 0; i--) { multiplesOf3and5(); if (i === 1) { print('length: ' + size + ' - sum: ' + sum); } }