summaryrefslogtreecommitdiff
path: root/benchmark/es
diff options
context:
space:
mode:
authorTimothy Gu <timothygu99@gmail.com>2017-03-19 16:05:55 -0700
committerTimothy Gu <timothygu99@gmail.com>2017-03-24 15:25:14 -0700
commita6e69f8c08958a0909a60b53d048b21d181e90e5 (patch)
treeb9342ce8fee3d0a6a298d5127d0503afe676b8e1 /benchmark/es
parentd9b0e4c729fedfe5369ada4229fd170bd6dc7e2f (diff)
downloadandroid-node-v8-a6e69f8c08958a0909a60b53d048b21d181e90e5.tar.gz
android-node-v8-a6e69f8c08958a0909a60b53d048b21d181e90e5.tar.bz2
android-node-v8-a6e69f8c08958a0909a60b53d048b21d181e90e5.zip
benchmark: add more options to map-bench
PR-URL: https://github.com/nodejs/node/pull/11930 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/es')
-rw-r--r--benchmark/es/map-bench.js42
1 files changed, 41 insertions, 1 deletions
diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js
index 047fc05abd..4663d71bdd 100644
--- a/benchmark/es/map-bench.js
+++ b/benchmark/es/map-bench.js
@@ -4,7 +4,10 @@ const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
- method: ['object', 'nullProtoObject', 'fakeMap', 'map'],
+ method: [
+ 'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject',
+ 'fakeMap', 'map'
+ ],
millions: [1]
});
@@ -36,6 +39,37 @@ function runNullProtoObject(n) {
bench.end(n / 1e6);
}
+function runNullProtoLiteralObject(n) {
+ const m = { __proto__: null };
+ var i = 0;
+ bench.start();
+ for (; i < n; i++) {
+ m['i' + i] = i;
+ m['s' + i] = String(i);
+ assert.strictEqual(String(m['i' + i]), m['s' + i]);
+ m['i' + i] = undefined;
+ m['s' + i] = undefined;
+ }
+ bench.end(n / 1e6);
+}
+
+function StorageObject() {}
+StorageObject.prototype = Object.create(null);
+
+function runStorageObject(n) {
+ const m = new StorageObject();
+ var i = 0;
+ bench.start();
+ for (; i < n; i++) {
+ m['i' + i] = i;
+ m['s' + i] = String(i);
+ assert.strictEqual(String(m['i' + i]), m['s' + i]);
+ m['i' + i] = undefined;
+ m['s' + i] = undefined;
+ }
+ bench.end(n / 1e6);
+}
+
function fakeMap() {
const m = {};
return {
@@ -84,6 +118,12 @@ function main(conf) {
case 'nullProtoObject':
runNullProtoObject(n);
break;
+ case 'nullProtoLiteralObject':
+ runNullProtoLiteralObject(n);
+ break;
+ case 'storageObject':
+ runStorageObject(n);
+ break;
case 'fakeMap':
runFakeMap(n);
break;