From 196a527504fd5a6ad45d53a2c8f350944ef12d48 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Mon, 10 May 2021 14:31:12 +0100 Subject: [PATCH] [api] Add benchmark for api accessors Bug: v8:11321 Change-Id: I330fb8ee7d915f99f9b82f7187be40ac33043f62 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2883625 Reviewed-by: Camillo Bruni Commit-Queue: Camillo Bruni Cr-Commit-Position: refs/heads/main@{#77340} --- test/js-perf-test/ApiAccessors/accessor.js | 14 ++++++++++++++ test/js-perf-test/ApiAccessors/run.js | 19 +++++++++++++++++++ test/js-perf-test/JSTests5.json | 11 +++++++++++ 3 files changed, 44 insertions(+) create mode 100644 test/js-perf-test/ApiAccessors/accessor.js create mode 100644 test/js-perf-test/ApiAccessors/run.js diff --git a/test/js-perf-test/ApiAccessors/accessor.js b/test/js-perf-test/ApiAccessors/accessor.js new file mode 100644 index 0000000000..1fa4b28d16 --- /dev/null +++ b/test/js-perf-test/ApiAccessors/accessor.js @@ -0,0 +1,14 @@ +// Copyright 2019 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 LoadNodeType() { + let node = new d8.dom.Div(); + + let result = 0; + for (var i = 0; i < 10e5; i++) { + result += node.nodeType; + } + + return result; +} +createSuite('nodeType', 1, LoadNodeType, ()=>{}); diff --git a/test/js-perf-test/ApiAccessors/run.js b/test/js-perf-test/ApiAccessors/run.js new file mode 100644 index 0000000000..930bae4292 --- /dev/null +++ b/test/js-perf-test/ApiAccessors/run.js @@ -0,0 +1,19 @@ +// Copyright 2019 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('accessor.js'); + +function PrintResult(name, result) { + console.log(name + '-ApiAccessors(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult(name, error); +} + +BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doDeterministic = undefined; + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError }); diff --git a/test/js-perf-test/JSTests5.json b/test/js-perf-test/JSTests5.json index e98b058ef3..0922a8a0b6 100644 --- a/test/js-perf-test/JSTests5.json +++ b/test/js-perf-test/JSTests5.json @@ -509,6 +509,17 @@ {"name": "NewIntlLocaleWithOptions"} ] }, + { + "name": "ApiAccessors", + "path": ["ApiAccessors"], + "main": "run.js", + "resources": [ "accessor.js" ], + "flags": [], + "results_regexp": "^%s\\-ApiAccessors\\(Score\\): (.+)$", + "tests": [ + {"name": "nodeType"} + ] + }, { "name": "Inspector", "path": ["Inspector"],