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: use object literal shorthands #12194

Closed
wants to merge 1 commit into from
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: 1 addition & 1 deletion benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Benchmark.prototype.report = function(rate, elapsed) {
sendResult({
name: this.name,
conf: this.config,
rate: rate,
rate,
time: elapsed[0] + elapsed[1] / 1e9,
type: 'report'
});
Expand Down
60 changes: 60 additions & 0 deletions benchmark/es/object-shorthands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

const common = require('../common.js');

const configs = {
n: [1e4],
mode: ['full', 'short'],
subject: ['properties', 'methods'],
};

const bench = common.createBenchmark(main, configs);

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

let obj;

if (conf.mode === 'properties') {
const a = 'a';
const b = 1;
const c = {};
const d = () => {};

if (conf.mode === 'full') {
bench.start();
for (let i = 0; i < n; i++)
obj = { a: a, b: b, c: c, d: d };
bench.end(n);
} else {
bench.start();
for (let i = 0; i < n; i++)
obj = { a, b, c, d };
bench.end(n);
}
} else {
if (conf.mode === 'full') {
bench.start();
for (let i = 0; i < n; i++)
obj = {
a: function a() {},
b: function b() {},
c: function c() {},
d: function d() {},
};
bench.end(n);
} else {
bench.start();
for (let i = 0; i < n; i++)
obj = {
a() {},
b() {},
c() {},
d() {},
};
bench.end(n);
}
}

return obj;
}
2 changes: 1 addition & 1 deletion benchmark/fs/read-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function runTest() {
assert(fs.statSync(filename).size === filesize);
var rs = fs.createReadStream(filename, {
highWaterMark: size,
encoding: encoding
encoding
});

rs.on('open', function() {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function main(conf) {
var path = '/' + conf.type + '/' + conf.length;

bench.http({
path: path,
path,
connections: conf.c
}, function() {
w1.destroy();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http/create-clientrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function main(conf) {
var n = +conf.n;

var path = '/'.repeat(pathlen);
var opts = { path: path, createConnection: function() {} };
var opts = { path, createConnection() {} };

bench.start();
for (var i = 0; i < n; i++) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function main(conf) {
conf.res;

bench.http({
path: path,
path,
connections: conf.c
}, function() {
server.close();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/misc/util-extend-vs-object-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function main(conf) {
for (var i = 0; i < conf.type.length * 10; i += 1)
fn({}, process.env);

var obj = new Proxy({}, { set: function(a, b, c) { return true; } });
var obj = new Proxy({}, { set(a, b, c) { return true; } });

bench.start();
for (var j = 0; j < n; j += 1)
Expand Down
8 changes: 4 additions & 4 deletions benchmark/misc/v8-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ load('navier-stokes.js');
const benchmark_name = path.join('misc', 'v8-bench.js');
const times = {};
global.BenchmarkSuite.RunSuites({
NotifyStart: function(name) {
NotifyStart(name) {
times[name] = process.hrtime();
},
NotifyResult: function(name, result) {
NotifyResult(name, result) {
const elapsed = process.hrtime(times[name]);
common.sendResult({
name: benchmark_name,
Expand All @@ -40,10 +40,10 @@ global.BenchmarkSuite.RunSuites({
time: elapsed[0] + elapsed[1] / 1e9
});
},
NotifyError: function(name, error) {
NotifyError(name, error) {
console.error(name + ': ' + error);
},
NotifyScore: function(score) {
NotifyScore(score) {
common.sendResult({
name: benchmark_name,
conf: {
Expand Down