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

benchmark: convert var to es6 const, let #12886

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
42 changes: 20 additions & 22 deletions benchmark/arrays/var-int.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
'use strict';
var common = require('../common.js');
const common = require('../common.js');

var types = [
'Array',
'Buffer',
'Int8Array',
'Uint8Array',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
];

var bench = common.createBenchmark(main, {
type: types,
const bench = common.createBenchmark(main, {
type: [
'Array',
'Buffer',
'Int8Array',
'Uint8Array',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
],
n: [25]
});

function main(conf) {
var type = conf.type;
var clazz = global[type];
var n = +conf.n;
const type = conf.type;
const clazz = global[type];
const n = +conf.n;

bench.start();
var arr = new clazz(n * 1e6);
for (var i = 0; i < 10; ++i) {
let arr = new clazz(n * 1e6);
for (let i = 0; i < 10; ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use let in the benchmarks, and let causes a noticeable performance deficit with current V8.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebasmurphy wait with the lets a month or two until we activate TurboFan and Ignition nodejs/CTC#99

run();
}
bench.end(n);

function run() {
for (var j = 0, k = arr.length; j < k; ++j) {
for (let j = 0, k = arr.length; j < k; ++j) {
arr[j] = (j ^ k) & 127;
}
}
Expand Down
42 changes: 20 additions & 22 deletions benchmark/arrays/zero-float.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
'use strict';
var common = require('../common.js');
const common = require('../common.js');

var types = [
'Array',
'Buffer',
'Int8Array',
'Uint8Array',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
];

var bench = common.createBenchmark(main, {
type: types,
const bench = common.createBenchmark(main, {
type: [
'Array',
'Buffer',
'Int8Array',
'Uint8Array',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
],
n: [25]
});

function main(conf) {
var type = conf.type;
var clazz = global[type];
var n = +conf.n;
const type = conf.type;
const clazz = global[type];
const n = +conf.n;

bench.start();
var arr = new clazz(n * 1e6);
for (var i = 0; i < 10; ++i) {
let arr = new clazz(n * 1e6);
for (let i = 0; i < 10; ++i) {
run();
}
bench.end(n);

function run() {
for (var j = 0, k = arr.length; j < k; ++j) {
for (let j = 0, k = arr.length; j < k; ++j) {
arr[j] = 0.0;
}
}
Expand Down
42 changes: 20 additions & 22 deletions benchmark/arrays/zero-int.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
'use strict';
var common = require('../common.js');
const common = require('../common.js');

var types = [
'Array',
'Buffer',
'Int8Array',
'Uint8Array',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
];

var bench = common.createBenchmark(main, {
type: types,
const bench = common.createBenchmark(main, {
type: [
'Array',
'Buffer',
'Int8Array',
'Uint8Array',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
],
n: [25]
});

function main(conf) {
var type = conf.type;
var clazz = global[type];
var n = +conf.n;
const type = conf.type;
const clazz = global[type];
const n = +conf.n;

bench.start();
var arr = new clazz(n * 1e6);
for (var i = 0; i < 10; ++i) {
let arr = new clazz(n * 1e6);
for (let i = 0; i < 10; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot the last one 😉

run();
}
bench.end(n);

function run() {
for (var j = 0, k = arr.length; j < k; ++j) {
for (let j = 0, k = arr.length; j < k; ++j) {
arr[j] = 0;
}
}
Expand Down