mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
// compare with "google-chrome deps/v8/benchmarks/run.html"
|
|
'use strict';
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
var vm = require('vm');
|
|
var common = require('../common.js');
|
|
|
|
var dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks');
|
|
|
|
function load(filename, inGlobal) {
|
|
var source = fs.readFileSync(path.join(dir, filename), 'utf8');
|
|
if (!inGlobal) source = '(function () {' + source + '\n})()';
|
|
vm.runInThisContext(source, { filename: 'v8/bechmark/' + filename });
|
|
}
|
|
|
|
load('base.js', true);
|
|
load('richards.js');
|
|
load('deltablue.js');
|
|
load('crypto.js');
|
|
load('raytrace.js');
|
|
load('earley-boyer.js');
|
|
load('regexp.js');
|
|
load('splay.js');
|
|
load('navier-stokes.js');
|
|
|
|
const times = {};
|
|
global.BenchmarkSuite.RunSuites({
|
|
NotifyStart: function(name) {
|
|
times[name] = process.hrtime();
|
|
},
|
|
NotifyResult: function(name, result) {
|
|
const elapsed = process.hrtime(times[name]);
|
|
common.sendResult({
|
|
name: name,
|
|
conf: {},
|
|
rate: result,
|
|
time: elapsed[0] + elapsed[1] / 1e9
|
|
});
|
|
},
|
|
NotifyError: function(name, error) {
|
|
console.error(name + ': ' + error);
|
|
},
|
|
NotifyScore: function(score) {
|
|
common.sendResult({
|
|
name: 'Score (version ' + global.BenchmarkSuite.version + ')',
|
|
conf: {},
|
|
rate: score,
|
|
time: 0
|
|
});
|
|
}
|
|
});
|
|
|