Files
control-pane/public/novnc/node_modules/es-module-loader/bench/runner.js
olevole e4c2ee15ae remove all ^M Dos carraige returns
better late than never, #55
2024-11-24 17:41:50 +03:00

48 lines
1.1 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import Benchmark from 'benchmark';
var benchmarks = fs.readdirSync('bench').filter(function(testName) {
return testName != 'runner.js' && testName.endsWith('.js')
});
process.on('unhandledRejection', function (e) {
setTimeout(function () {
throw e;
});
});
function runNextBenchmark() {
var nextBenchmark = benchmarks.shift();
if (!nextBenchmark)
return Promise.resolve();
global.suite = new Benchmark.Suite;
console.log('--- ' + nextBenchmark.substr(0, nextBenchmark.length - 3) + ' ---');
return loader.import(path.resolve('bench/' + nextBenchmark))
.then(function() {
return new Promise(function(resolve, reject) {
suite.on('cycle', function(event) {
console.log(event.target.error ? event.target.error : String(event.target));
});
suite.on('complete', function(event) {
console.log('Fastest is ' + this.filter('fastest').map('name') + '\n');
resolve();
});
suite.on('error', reject);
suite.run({ defer: true });
});
})
.then(function() {
return runNextBenchmark();
});
}
runNextBenchmark();