node/benchmark/misc/v8-bench.js

23 lines
692 B
JavaScript
Raw Normal View History

2011-02-15 09:26:54 +08:00
// compare with "google-chrome deps/v8/benchmarks/run.html"
var fs = require('fs');
var path = require('path');
var vm = require('vm');
2013-02-12 15:10:12 +08:00
var dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks');
2011-02-15 09:26:54 +08:00
2013-02-12 15:10:12 +08:00
global.print = function(s) {
if (s === '----') return;
console.log('misc/v8_bench.js %s', s);
};
2011-02-15 09:26:54 +08:00
global.load = function(filename) {
var source = fs.readFileSync(path.join(dir, filename), 'utf8');
// deps/v8/benchmarks/regexp.js breaks console.log() because it clobbers
// the RegExp global, Restore the original when the script is done.
var $RegExp = global.RegExp;
vm.runInThisContext(source, { filename: filename });
global.RegExp = $RegExp;
};
2011-02-15 09:26:54 +08:00
load('run.js');