add micro-benchmark for proxy trap setPrototypeOf

Bug: v8:6664
Change-Id: If5a8a85a7537fa429fb58d1e0654ffe5f6a5897f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1669788
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62363}
This commit is contained in:
Z Nguyen-Huu 2019-06-25 08:43:50 -07:00 committed by Commit Bot
parent 5ff38bae08
commit 139f83110c
2 changed files with 42 additions and 1 deletions

View File

@ -39,7 +39,9 @@
{"name": "PreventExtensionsWithoutTrap"},
{"name": "PreventExtensionsWithTrap"},
{"name": "GetPrototypeOfWithoutTrap"},
{"name": "GetPrototypeOfWithTrap"}
{"name": "GetPrototypeOfWithTrap"},
{"name": "SetPrototypeOfWithoutTrap"},
{"name": "SetPrototypeOfWithTrap"}
]
},
{

View File

@ -625,3 +625,42 @@ newBenchmark("GetPrototypeOfWithTrap", {
},
teardown() {}
});
// ----------------------------------------------------------------------------
newBenchmark("SetPrototypeOfWithoutTrap", {
setup() {
var obj = { x: 1 };
obj.__proto__ = {};
p = new Proxy(obj, {});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
value = Object.setPrototypeOf(p, [1]);
}
return value;
},
teardown() {}
});
// ----------------------------------------------------------------------------
newBenchmark("SetPrototypeOfWithTrap", {
setup() {
var obj = { x: 1 };
obj.__proto__ = {};
p = new Proxy(obj, {
setPrototypeOf: function(target, proto) {
Object.setPrototypeOf(target, proto);
return true;
}
});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
value = Object.setPrototypeOf(p, [1]);
}
return value;
},
teardown() {}
});