Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Test Benchmark for es #16076

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions benchmark/es/defaultparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function main(conf) {
const n = +conf.millions * 1e6;

switch (conf.method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'withoutdefaults':
runOldStyleDefaults(n);
break;
Expand Down
2 changes: 2 additions & 0 deletions benchmark/es/destructuring-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function main(conf) {
const n = +conf.millions * 1e6;

switch (conf.method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'swap':
runSwapManual(n);
break;
Expand Down
2 changes: 2 additions & 0 deletions benchmark/es/destructuring-object-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function main(conf) {
const n = +conf.millions * 1e6;

switch (conf.method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'normal':
runNormal(n);
break;
Expand Down
2 changes: 2 additions & 0 deletions benchmark/es/foreach-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function main(conf) {
items[i] = i;

switch (conf.method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'for':
fn = useFor;
break;
Expand Down
2 changes: 2 additions & 0 deletions benchmark/es/map-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ function main(conf) {
const n = +conf.millions * 1e6;

switch (conf.method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'object':
runObject(n);
break;
Expand Down
2 changes: 2 additions & 0 deletions benchmark/es/restparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ function main(conf) {
const n = +conf.millions * 1e6;

switch (conf.method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'copy':
runCopyArguments(n);
break;
Expand Down
2 changes: 2 additions & 0 deletions benchmark/es/spread-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function main(conf) {
args[i] = i;

switch (conf.method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'apply':
bench.start();
for (i = 0; i < n; i++)
Expand Down
7 changes: 5 additions & 2 deletions benchmark/es/string-concatenations.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ const bench = common.createBenchmark(main, configs);

function main(conf) {
const n = +conf.n;
const mode = conf.mode;

const str = 'abc';
const num = 123;

let string;

switch (mode) {
switch (conf.mode) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'multi-concat':
bench.start();
for (let i = 0; i < n; i++)
Expand Down Expand Up @@ -63,6 +64,8 @@ function main(conf) {
string = `${num}`;
bench.end(n);
break;
default:
throw new Error('Unexpected method');
}

return string;
Expand Down
27 changes: 17 additions & 10 deletions benchmark/es/string-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,23 @@ function main(conf) {

let str;

if (conf.mode === 'Array') {
bench.start();
for (let i = 0; i < n; i++)
str = new Array(size + 1).join(character);
bench.end(n);
} else {
bench.start();
for (let i = 0; i < n; i++)
str = character.repeat(size);
bench.end(n);
switch (conf.mode) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'Array':
bench.start();
for (let i = 0; i < n; i++)
str = new Array(size + 1).join(character);
bench.end(n);
break;
case 'repeat':
bench.start();
for (let i = 0; i < n; i++)
str = character.repeat(size);
bench.end(n);
break;
default:
throw new Error('Unexpected method');
}

assert.strictEqual([...str].length, size);
Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-benchmark-es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

require('../common');

const runBenchmark = require('../common/benchmark');

runBenchmark('es',
[
'method=',
'millions=0.000001',
'count=1',
'context=null',
'rest=0',
'mode=',
'n=1',
'encoding=ascii',
'size=1e1'
]);