Implement micro-benchmark for Proxies constructor
Bug: Change-Id: I95285260b0848c4c876498bfef0b13ffbe6855ad Reviewed-on: https://chromium-review.googlesource.com/558297 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Maya Lekova <mslekova@google.com> Cr-Commit-Position: refs/heads/master@{#46415}
This commit is contained in:
parent
53d68701c2
commit
02ce935ad3
@ -8,6 +8,19 @@
|
||||
"total": true,
|
||||
"resources": ["base.js"],
|
||||
"tests": [
|
||||
{
|
||||
"name": "Proxies",
|
||||
"path": ["Proxies"],
|
||||
"main": "run.js",
|
||||
"resources": ["proxies.js"],
|
||||
"results_regexp": "^%s\\-Proxies\\(Score\\): (.+)$",
|
||||
"tests": [
|
||||
{"name": "ProxyConstructorWithArrowFunc"},
|
||||
{"name": "ProxyConstructorWithClass"},
|
||||
{"name": "ProxyConstructorWithObject"},
|
||||
{"name": "ProxyConstructorWithProxy"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AsyncAwait",
|
||||
"path": ["AsyncAwait"],
|
||||
|
71
test/js-perf-test/Proxies/proxies.js
Normal file
71
test/js-perf-test/Proxies/proxies.js
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
function newBenchmark(name, handlers) {
|
||||
new BenchmarkSuite(name, [1000], [
|
||||
new Benchmark(name, false, false, 0,
|
||||
handlers.run, handlers.setup, handlers.teardown)
|
||||
]);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
var result;
|
||||
var foo = () => {}
|
||||
|
||||
newBenchmark("ProxyConstructorWithArrowFunc", {
|
||||
setup() { },
|
||||
run() {
|
||||
var proxy = new Proxy(foo, {});
|
||||
result = proxy;
|
||||
},
|
||||
teardown() {
|
||||
return (typeof result == 'function');
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class Class {};
|
||||
|
||||
newBenchmark("ProxyConstructorWithClass", {
|
||||
setup() { },
|
||||
run() {
|
||||
var proxy = new Proxy(Class, {});
|
||||
result = proxy;
|
||||
},
|
||||
teardown() {
|
||||
return (typeof result == 'function');
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
var obj = {};
|
||||
|
||||
newBenchmark("ProxyConstructorWithObject", {
|
||||
setup() { },
|
||||
run() {
|
||||
var proxy = new Proxy(obj, {});
|
||||
result = proxy;
|
||||
},
|
||||
teardown() {
|
||||
return (typeof result == 'function');
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
var p = new Proxy({}, {});
|
||||
|
||||
newBenchmark("ProxyConstructorWithProxy", {
|
||||
setup() { },
|
||||
run() {
|
||||
var proxy = new Proxy(p, {});
|
||||
result = proxy;
|
||||
},
|
||||
teardown() {
|
||||
return (typeof result == 'function');
|
||||
}
|
||||
});
|
26
test/js-perf-test/Proxies/run.js
Normal file
26
test/js-perf-test/Proxies/run.js
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2015 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
load('../base.js');
|
||||
load('proxies.js');
|
||||
|
||||
var success = true;
|
||||
|
||||
function PrintResult(name, result) {
|
||||
print(name + '-Proxies(Score): ' + result);
|
||||
}
|
||||
|
||||
|
||||
function PrintError(name, error) {
|
||||
PrintResult(name, error);
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
||||
BenchmarkSuite.config.doWarmup = undefined;
|
||||
BenchmarkSuite.config.doDeterministic = undefined;
|
||||
|
||||
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
|
||||
NotifyError: PrintError });
|
Loading…
Reference in New Issue
Block a user