From f021c622a9508ca26824ce8e02f270a2a396a70f Mon Sep 17 00:00:00 2001 From: Z Nguyen-Huu Date: Mon, 17 Jun 2019 10:43:30 -0700 Subject: [PATCH] add micro-benchmark for proxy trap getPrototypeOf Bug: v8:664 Change-Id: I180a59462bd22a1f2378a59fd31edbb539603a1f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1659569 Commit-Queue: Z Nguyen-Huu Reviewed-by: Maya Lekova Reviewed-by: Jakob Gruber Cr-Commit-Position: refs/heads/master@{#62227} --- test/js-perf-test/JSTests4.json | 4 +++- test/js-perf-test/Proxies/proxies.js | 34 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/test/js-perf-test/JSTests4.json b/test/js-perf-test/JSTests4.json index 5c98e71b51..eb02b05d2f 100644 --- a/test/js-perf-test/JSTests4.json +++ b/test/js-perf-test/JSTests4.json @@ -37,7 +37,9 @@ {"name": "IsExtensibleWithoutTrap"}, {"name": "IsExtensibleWithTrap"}, {"name": "PreventExtensionsWithoutTrap"}, - {"name": "PreventExtensionsWithTrap"} + {"name": "PreventExtensionsWithTrap"}, + {"name": "GetPrototypeOfWithoutTrap"}, + {"name": "GetPrototypeOfWithTrap"} ] }, { diff --git a/test/js-perf-test/Proxies/proxies.js b/test/js-perf-test/Proxies/proxies.js index 17476d895e..9c9a612945 100644 --- a/test/js-perf-test/Proxies/proxies.js +++ b/test/js-perf-test/Proxies/proxies.js @@ -591,3 +591,37 @@ newBenchmark("PreventExtensionsWithTrap", { }, teardown() {} }); + +// ---------------------------------------------------------------------------- + +newBenchmark("GetPrototypeOfWithoutTrap", { + setup() { + p = new Proxy({}, {}); + }, + run() { + for(var i = 0; i < ITERATIONS; i++) { + value = Object.getPrototypeOf(p); + } + return value; + }, + teardown() {} +}); + +// ---------------------------------------------------------------------------- + +newBenchmark("GetPrototypeOfWithTrap", { + setup() { + p = new Proxy({}, { + getPrototypeOf: function(target) { + return Array.prototype; + } + }); + }, + run() { + for(var i = 0; i < ITERATIONS; i++) { + value = Object.getPrototypeOf(p); + } + return value; + }, + teardown() {} +});