Andrew Top | 63c7ad4 | 2019-11-25 16:10:13 -0800 | [diff] [blame] | 1 | // Copyright 2018 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | new BenchmarkSuite("SingleLineString", [1000], [ |
| 6 | new Benchmark("SingleLineString", false, true, iterations, Run, SingleLineStringSetup) |
| 7 | ]); |
| 8 | |
| 9 | new BenchmarkSuite("SingleLineStrings", [3000], [ |
| 10 | new Benchmark("SingleLineStrings", false, true, iterations, Run, SingleLineStringsSetup) |
| 11 | ]); |
| 12 | |
| 13 | new BenchmarkSuite("MultiLineString", [1000], [ |
| 14 | new Benchmark("MultiLineString", false, true, iterations, Run, MultiLineStringSetup) |
| 15 | ]); |
| 16 | |
| 17 | function SingleLineStringSetup() { |
| 18 | code = "\"" + "This is a string".repeat(600) + "\""; |
| 19 | %FlattenString(code); |
| 20 | } |
| 21 | |
| 22 | function SingleLineStringsSetup() { |
| 23 | code = "\"This is a string\"\n".repeat(600); |
| 24 | %FlattenString(code); |
| 25 | } |
| 26 | |
| 27 | function MultiLineStringSetup() { |
| 28 | code = "\"" + "This is a string \\\n".repeat(600) + "\""; |
| 29 | %FlattenString(code); |
| 30 | } |
| 31 | |
| 32 | function Run() { |
| 33 | if (code == undefined) { |
| 34 | throw new Error("No test data"); |
| 35 | } |
| 36 | eval(code); |
| 37 | } |