Skip to content

Commit

Permalink
benchmark: compare strings with strict equality operators
Browse files Browse the repository at this point in the history
This patch makes sure that the strings are compared with strict
equality operators.
  • Loading branch information
thefourtheye committed Aug 27, 2015
1 parent 3cc6485 commit 301e14f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function runBenchmarks() {
if (test.match(/^[\._]/))
return process.nextTick(runBenchmarks);

if (outputFormat == 'default')
if (outputFormat === 'default')
console.error(type + '/' + test);

test = path.resolve(dir, test);
Expand Down Expand Up @@ -160,7 +160,7 @@ Benchmark.prototype._run = function() {
}, [[main]]);

// output csv heading
if (outputFormat == 'csv')
if (outputFormat === 'csv')
console.log('filename,' + Object.keys(options).join(',') + ',result');

var node = process.execPath;
Expand Down Expand Up @@ -229,9 +229,9 @@ Benchmark.prototype.end = function(operations) {
Benchmark.prototype.report = function(value) {
var heading = this.getHeading();

if (outputFormat == 'default')
if (outputFormat === 'default')
console.log('%s: %s', heading, value.toFixed(5));
else if (outputFormat == 'csv')
else if (outputFormat === 'csv')
console.log('%s,%s', heading, value.toFixed(5));

process.exit(0);
Expand All @@ -240,11 +240,11 @@ Benchmark.prototype.report = function(value) {
Benchmark.prototype.getHeading = function() {
var conf = this.config;

if (outputFormat == 'default') {
if (outputFormat === 'default') {
return this._name + ' ' + Object.keys(conf).map(function(key) {
return key + '=' + conf[key];
}).join(' ');
} else if (outputFormat == 'csv') {
} else if (outputFormat === 'csv') {
return this._name + ',' + Object.keys(conf).map(function(key) {
return conf[key];
}).join(',');
Expand Down
12 changes: 6 additions & 6 deletions benchmark/http_simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var server = module.exports = http.createServer(function (req, res) {
var n_chunks = parseInt(commands[3], 10);
var status = 200;

if (command == 'bytes') {
if (command === 'bytes') {
var n = ~~arg;
if (n <= 0)
throw new Error('bytes called with n <= 0')
Expand All @@ -45,7 +45,7 @@ var server = module.exports = http.createServer(function (req, res) {
}
body = storedBytes[n];

} else if (command == 'buffer') {
} else if (command === 'buffer') {
var n = ~~arg;
if (n <= 0)
throw new Error('buffer called with n <= 0');
Expand All @@ -57,7 +57,7 @@ var server = module.exports = http.createServer(function (req, res) {
}
body = storedBuffer[n];

} else if (command == 'unicode') {
} else if (command === 'unicode') {
var n = ~~arg;
if (n <= 0)
throw new Error('unicode called with n <= 0');
Expand All @@ -66,14 +66,14 @@ var server = module.exports = http.createServer(function (req, res) {
}
body = storedUnicode[n];

} else if (command == 'quit') {
} else if (command === 'quit') {
res.connection.server.close();
body = 'quitting';

} else if (command == 'fixed') {
} else if (command === 'fixed') {
body = fixed;

} else if (command == 'echo') {
} else if (command === 'echo') {
res.writeHead(200, { 'Content-Type': 'text/plain',
'Transfer-Encoding': 'chunked' });
req.pipe(res);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http_simple_auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ server.listen(port, function () {
});

function dump_mm_stats() {
if (typeof gc != 'function') return;
if (typeof gc !== 'function') return;

var before = process.memoryUsage();
for (var i = 0; i < 10; ++i) gc();
Expand Down

0 comments on commit 301e14f

Please sign in to comment.