Skip to content
Closed
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
Prev Previous commit
Next Next commit
squash
  • Loading branch information
rvagg committed Oct 18, 2016
commit 15bd927639dd0b84c9aa2700cb86b1a91f62b624
44 changes: 22 additions & 22 deletions benchmark/es/map-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ const assert = require('assert');

const bench = common.createBenchmark(main, {
method: ['object', 'nullProtoObject', 'fakeMap', 'map'],
millions: [10]
thousands: [100]
});

function runObject(n) {
const m = {};
var i = 0;
bench.start();
for (; i < n; i++) {
m['i' + n] = n;
m['s' + n] = String(n);
assert.equal(m['i' + n], m['s' + n]);
m['i' + n] = undefined;
m['s' + n] = undefined;
m['i' + i] = i;
m['s' + i] = String(i);
assert.equal(m['i' + i], m['s' + i]);
m['i' + i] = undefined;
m['s' + i] = undefined;
}
bench.end(n / 1e6);
}
Expand All @@ -27,11 +27,11 @@ function runNullProtoObject(n) {
var i = 0;
bench.start();
for (; i < n; i++) {
m['i' + n] = n;
m['s' + n] = String(n);
assert.equal(m['i' + n], m['s' + n]);
m['i' + n] = undefined;
m['s' + n] = undefined;
m['i' + i] = i;
m['s' + i] = String(i);
assert.equal(m['i' + i], m['s' + i]);
m['i' + i] = undefined;
m['s' + i] = undefined;
}
bench.end(n / 1e6);
}
Expand All @@ -51,11 +51,11 @@ function runFakeMap(n) {
var i = 0;
bench.start();
for (; i < n; i++) {
m.set('i' + n, n);
m.set('s' + n, String(n));
assert.equal(m.get('i' + n), m.get('s' + n));
m.set('i' + n, undefined);
m.set('s' + n, undefined);
m.set('i' + i, i);
m.set('s' + i, String(i));
assert.equal(m.get('i' + i), m.get('s' + i));
m.set('i' + i, undefined);
m.set('s' + i, undefined);
}
bench.end(n / 1e6);
}
Expand All @@ -65,17 +65,17 @@ function runMap(n) {
var i = 0;
bench.start();
for (; i < n; i++) {
m.set('i' + n, n);
m.set('s' + n, String(n));
assert.equal(m.get('i' + n), m.get('s' + n));
m.set('i' + n, undefined);
m.set('s' + n, undefined);
m.set('i' + i, i);
m.set('s' + i, String(i));
assert.equal(m.get('i' + i), m.get('s' + i));
m.set('i' + i, undefined);
m.set('s' + i, undefined);
}
bench.end(n / 1e6);
}

function main(conf) {
const n = +conf.millions * 1e6;
const n = +conf.thousands * 1000;

switch (conf.method) {
case 'object':
Expand Down