Commit 7280d03b authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

Implement micro-benchmark for Proxy call and construct

Bug: v8:6558, v8:6557
Change-Id: Ife58f78d00bfd53d6b904e838cbd028f039945b4
Reviewed-on: https://chromium-review.googlesource.com/567501
Commit-Queue: Maya Lekova <mslekova@google.com>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46588}
parent cad3c5a1
......@@ -69,3 +69,85 @@ newBenchmark("ProxyConstructorWithProxy", {
return (typeof result == 'function');
}
});
// ----------------------------------------------------------------------------
const SOME_NUMBER = 42;
const SOME_OTHER_NUMBER = 1337;
const ITERATIONS = 1000;
newBenchmark("CallProxyWithoutTrap", {
setup() {
const target = () => { return SOME_NUMBER; };
p = new Proxy(target, {});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
p();
}
},
teardown() {
return (result === SOME_NUMBER);
}
});
// ----------------------------------------------------------------------------
newBenchmark("CallProxyWithTrap", {
setup() {
const target = () => { return SOME_NUMBER; };
p = new Proxy(target, {
apply: function(target, thisArg, argumentsList) {
return SOME_OTHER_NUMBER;
}
});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
p();
}
},
teardown() {
return (result === SOME_OTHER_NUMBER);
}
});
var instance;
class MyClass {
};
// ----------------------------------------------------------------------------
newBenchmark("ConstructProxyWithoutTrap", {
setup() {
p = new Proxy(MyClass, {});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
instance = new p();
}
},
teardown() {
return instance instanceof MyClass;
}
});
// ----------------------------------------------------------------------------
newBenchmark("ConstructProxyWithTrap", {
setup() {
p = new Proxy(Object, {
construct: function(target, argumentsList, newTarget) {
return new MyClass;
}
});
},
run() {
for(var i = 0; i < ITERATIONS; i++) {
instance = new p();
}
},
teardown() {
return instance instanceof MyClass;
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment