Skip to content

Commit

Permalink
Convert all benchmarks to typescript. (#835)
Browse files Browse the repository at this point in the history
Support multiple tests in a target
  • Loading branch information
TwitchBronBron authored Jul 10, 2023
1 parent 38f801e commit daae317
Show file tree
Hide file tree
Showing 15 changed files with 6,542 additions and 3,944 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ module.exports = {
{
files: ['benchmarks/**/*.ts'],
rules: {
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'camelcase': 'off'
Expand Down
14 changes: 9 additions & 5 deletions benchmarks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from 'path';
import * as fs from 'fs';
const cwd = __dirname;
const tempDir = path.join(cwd, '.tmp');
let nodeArgs = ['--max-old-space-size=8192'];
let MAX_OLD_SPACE = 8192;

clean();
execSync('npm install');
Expand Down Expand Up @@ -97,7 +97,7 @@ class Runner {
*/
prepare() {
const dependencies = {};
console.log(`benchmark: using versions: ${this.options.versions}`);
console.log(`benchmark: using versions: ${this.options.versions.join(', ')}`);
for (let i = 0; i < this.options.versions.length; i++) {
const version = this.options.versions[i];
const name = `brighterscript${i + 1}`;
Expand Down Expand Up @@ -144,7 +144,11 @@ class Runner {
cwd: cwd
});

execSync(`node ${nodeArgs.join(' ')} target-runner.js "${version}" "${maxVersionLength}" "${target}" "${maxTargetLength}" "${alias}" "${this.options.project}" "${this.options.quick}" "${this.options.profile}"`);
execSync(`npx ts-node target-runner.ts "${version}" "${maxVersionLength}" "${target}" "${maxTargetLength}" "${alias}" "${this.options.project}" "${this.options.quick}" "${this.options.profile}"`, {
env: {
'NODE_OPTIONS': `--max-old-space-size=${MAX_OLD_SPACE}`
}
});
if (this.options.profile) {
const logFile = fastGlob.sync('isolate-*.log', {
cwd: cwd
Expand All @@ -157,7 +161,7 @@ class Runner {
}
}

let targets = fsExtra.readdirSync('./targets').map(x => x.replace('.js', ''));
let targets = fsExtra.readdirSync('./targets').map(x => x.replace(/\.(js|ts)/, ''));

let options = yargs
.usage('$0', 'bsc benchmark tool')
Expand Down Expand Up @@ -215,7 +219,7 @@ const runner = new Runner(options as any);
runner.run();

function execSync(command: string, options: ExecSyncOptions = {}) {
console.log(command);
// console.log(`Executing '${command}'`);
return childProcess.execSync(command, { stdio: 'inherit', cwd: cwd, ...options });
}

Expand Down
Loading

0 comments on commit daae317

Please sign in to comment.