2011-02-15 02:26:54 +01:00
|
|
|
// compare with "google-chrome deps/v8/benchmarks/run.html"
|
2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2011-02-15 02:26:54 +01:00
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var vm = require('vm');
|
2016-02-01 11:30:00 +01:00
|
|
|
var common = require('../common.js');
|
2011-02-15 02:26:54 +01:00
|
|
|
|
2013-02-12 08:10:12 +01:00
|
|
|
var dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks');
|
2011-02-15 02:26:54 +01:00
|
|
|
|
2016-02-01 11:30:00 +01:00
|
|
|
function load(filename, inGlobal) {
|
2015-01-17 20:12:29 +01:00
|
|
|
var source = fs.readFileSync(path.join(dir, filename), 'utf8');
|
2016-02-01 11:30:00 +01:00
|
|
|
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');
|
2011-02-15 02:26:54 +01:00
|
|
|
|
2016-09-16 12:01:51 +02:00
|
|
|
const benchmark_name = path.join('misc', 'v8-bench.js');
|
2016-02-01 11:30:00 +01:00
|
|
|
const times = {};
|
|
|
|
global.BenchmarkSuite.RunSuites({
|
|
|
|
NotifyStart: function(name) {
|
|
|
|
times[name] = process.hrtime();
|
|
|
|
},
|
|
|
|
NotifyResult: function(name, result) {
|
|
|
|
const elapsed = process.hrtime(times[name]);
|
|
|
|
common.sendResult({
|
2016-09-16 12:01:51 +02:00
|
|
|
name: benchmark_name,
|
|
|
|
conf: {
|
|
|
|
benchmark: name
|
|
|
|
},
|
2016-02-01 11:30:00 +01:00
|
|
|
rate: result,
|
|
|
|
time: elapsed[0] + elapsed[1] / 1e9
|
|
|
|
});
|
|
|
|
},
|
|
|
|
NotifyError: function(name, error) {
|
|
|
|
console.error(name + ': ' + error);
|
|
|
|
},
|
|
|
|
NotifyScore: function(score) {
|
|
|
|
common.sendResult({
|
2016-09-16 12:01:51 +02:00
|
|
|
name: benchmark_name,
|
|
|
|
conf: {
|
|
|
|
benchmark: 'Score (version ' + global.BenchmarkSuite.version + ')'
|
|
|
|
},
|
2016-02-01 11:30:00 +01:00
|
|
|
rate: score,
|
|
|
|
time: 0
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|