From 10f2a1a6490f45c114aa72a9e75b50819cf62019 Mon Sep 17 00:00:00 2001 From: Dan Elphick Date: Fri, 12 Jan 2018 15:32:45 +0000 Subject: [PATCH] Create js-perf-test for Array.of Add tests with a few Array.of invocations in preparation for adding a CodeStubAssembler generated version. Change-Id: I5aee3f32a584ae31cebcbbe6b0e5491a4bc1da34 Reviewed-on: https://chromium-review.googlesource.com/861884 Reviewed-by: Ross McIlroy Commit-Queue: Dan Elphick Cr-Commit-Position: refs/heads/master@{#50550} --- test/js-perf-test/Array/of.js | 121 +++++++++++++++++++++++++++++++++ test/js-perf-test/Array/run.js | 1 + test/js-perf-test/JSTests.json | 11 ++- 3 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 test/js-perf-test/Array/of.js diff --git a/test/js-perf-test/Array/of.js b/test/js-perf-test/Array/of.js new file mode 100644 index 0000000000..25f7e0446e --- /dev/null +++ b/test/js-perf-test/Array/of.js @@ -0,0 +1,121 @@ +// Copyright 2018 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 benchy(name, test, testSetup) { + new BenchmarkSuite(name, [1000], + [ + new Benchmark(name, false, false, 0, test, testSetup, ()=>{}) + ]); +} + +benchy('EmptyArrayOf', EmptyArrayOf, EmptyArrayOfSetup); +benchy('SmallTransplantedArrayOf', SmallTransplantedArrayOf, + SmallTransplantedArrayOfSetup); +benchy('SmallSmiArrayOf', SmallSmiArrayOf, SmallSmiArrayOfSetup); +benchy('LargeSmiArrayOf', LargeSmiArrayOf, LargeSmiArrayOfSetup); +benchy('SmallDoubleArrayOf', SmallDoubleArrayOf, SmallDoubleArrayOfSetup); +benchy('SmallStringArrayOf', SmallStringArrayOf, SmallStringArrayOfSetup); +benchy('SmallMixedArrayOf', SmallMixedArrayOf, SmallMixedArrayOfSetup); + +function ArrayLike() {} +ArrayLike.of = Array.of; + +var arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 +var arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20 +var result; + +function EmptyArrayOf() { + result = Array.of(); +} + +function BaselineArray() { + result = [arg1, arg2, arg3]; +} + +function SmallSmiArrayOf() { + result = Array.of(arg1, arg2, arg3); +} + +function LargeSmiArrayOf() { + result = Array.of(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, + arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20); +} + +function SmallTransplantedArrayOf() { + result = ArrayLike.of(arg1, arg2, arg3); +} + +function SmallDoubleArrayOf() { + result = Array.of(arg1, arg2, arg3); +} + +function SmallStringArrayOf() { + result = Array.of(arg1, arg2, arg3); +} + +function SmallMixedArrayOf() { + result = Array.of(arg1, arg2, arg3); +} + +function EmptyArrayOfSetup() { +} + +function BaselineArraySetup() { + arg1 = 1; + arg2 = 2; + arg3 = 3; +} + +function SmallSmiArrayOfSetup() { + arg1 = 1; + arg2 = 2; + arg3 = 3; +} + +function SmallTransplantedArrayOfSetup() { + arg1 = 1; + arg2 = 2; + arg3 = 3; +} + +function SmallDoubleArrayOfSetup() { + arg1 = 1.5; + arg2 = 2.5; + arg3 = 3.5; +} + +function SmallStringArrayOfSetup() { + arg1 = "cat"; + arg2 = "dog"; + arg3 = "giraffe"; +} + +function SmallMixedArrayOfSetup() { + arg1 = 1; + arg2 = 2.5; + arg3 = "giraffe"; +} + +function LargeSmiArrayOfSetup() { + arg1 = 1; + arg2 = 2; + arg3 = 3; + arg4 = 4; + arg5 = 5; + arg6 = 6; + arg7 = 7; + arg8 = 8; + arg9 = 9; + arg10 = 10; + arg11 = 11; + arg12 = 12; + arg13 = 13; + arg14 = 14; + arg15 = 15; + arg16 = 16; + arg17 = 17; + arg18 = 18; + arg19 = 19; + arg20 = 20; +} diff --git a/test/js-perf-test/Array/run.js b/test/js-perf-test/Array/run.js index e7ef3e129d..d05928a375 100644 --- a/test/js-perf-test/Array/run.js +++ b/test/js-perf-test/Array/run.js @@ -15,6 +15,7 @@ load('reduce-right.js'); load('to-string.js'); load('find.js'); load('find-index.js'); +load('of.js'); var success = true; diff --git a/test/js-perf-test/JSTests.json b/test/js-perf-test/JSTests.json index 0b22c235ab..d2c1152425 100644 --- a/test/js-perf-test/JSTests.json +++ b/test/js-perf-test/JSTests.json @@ -397,7 +397,7 @@ "resources": [ "filter.js", "map.js", "every.js", "join.js", "some.js", "reduce.js", "reduce-right.js", "to-string.js", "find.js", - "find-index.js" + "find-index.js", "of.js" ], "flags": [ "--allow-natives-syntax" @@ -451,7 +451,14 @@ {"name": "SmiFindIndex"}, {"name": "FastFindIndex"}, {"name": "GenericFindIndex"}, - {"name": "OptFastFindIndex"} + {"name": "OptFastFindIndex"}, + {"name": "EmptyArrayOf"}, + {"name": "SmallSmiArrayOf"}, + {"name": "LargeSmiArrayOf"}, + {"name": "SmallTransplantedArrayOf"}, + {"name": "SmallDoubleArrayOf"}, + {"name": "SmallStringArrayOf"}, + {"name": "SmallMixedArrayOf"} ] }, {