Add micro-benchmark for Proxy has property

Bug: v8:6664, v8:6557
Change-Id: Ib0f9b258d49f96bee041cbcfc589f3ec91e013ed
Reviewed-on: https://chromium-review.googlesource.com/597859
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Maya Lekova <mslekova@google.com>
Cr-Commit-Position: refs/heads/master@{#47110}
This commit is contained in:
Maya Lekova 2017-08-02 15:27:56 +02:00 committed by Commit Bot
parent 3bccb99557
commit c772d8d983
2 changed files with 40 additions and 1 deletions

View File

@ -24,7 +24,9 @@
{"name": "ConstructProxyWithoutTrap"},
{"name": "ConstructProxyWithTrap"},
{"name": "GetPropertyOfProxyWithoutTrap"},
{"name": "GetPropertyOfProxyWithTrap"}
{"name": "GetPropertyOfProxyWithTrap"},
{"name": "HasOnProxyWithoutTrap"},
{"name": "HasOnProxyWithTrap"}
]
},
{

View File

@ -192,3 +192,40 @@ newBenchmark("GetPropertyOfProxyWithTrap", {
return value === SOME_OTHER_NUMBER;
}
});
// ----------------------------------------------------------------------------
obj = {};
newBenchmark("HasOnProxyWithoutTrap", {
setup() {
p = new Proxy(obj, {});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
value = ('prop' in p);
}
},
teardown() {
return value === true;
}
});
// ----------------------------------------------------------------------------
newBenchmark("HasOnProxyWithTrap", {
setup() {
p = new Proxy(obj, {
has: function(target, propertyKey) {
return true;
}
});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
value = ('prop' in p);
}
},
teardown() {
return value === true;
}
});