arrowfunctions.js 1.97 KB
Newer Older
1 2 3 4
// 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.

5
new BenchmarkSuite("ArrowFunctionShort", [1000], [
6 7 8
  new Benchmark("ArrowFunctionShort", false, true, iterations, Run, ArrowFunctionShortSetup)
]);

9
new BenchmarkSuite("ArrowFunctionLong", [1000], [
10 11 12
  new Benchmark("ArrowFunctionLong", false, true, iterations, Run, ArrowFunctionLongSetup)
]);

13
new BenchmarkSuite("CommaSepExpressionListShort", [1000], [
14 15 16
  new Benchmark("CommaSepExpressionListShort", false, true, iterations, Run, CommaSepExpressionListShortSetup)
]);

17
new BenchmarkSuite("CommaSepExpressionListLong", [1000], [
18 19 20
  new Benchmark("CommaSepExpressionListLong", false, true, iterations, Run, CommaSepExpressionListLongSetup)
]);

21
new BenchmarkSuite("CommaSepExpressionListLate", [1000], [
22 23 24
  new Benchmark("CommaSepExpressionListLate", false, true, iterations, Run, CommaSepExpressionListLateSetup)
]);

25
new BenchmarkSuite("FakeArrowFunction", [1000], [
26 27 28 29
  new Benchmark("FakeArrowFunction", false, true, iterations, Run, FakeArrowFunctionSetup)
]);

function ArrowFunctionShortSetup() {
30
  code = "let a;\n" + "a = (a,b) => { return a+b; }\n".repeat(50)
31 32 33
}

function ArrowFunctionLongSetup() {
34
  code = "let a;\n" + "a = (a,b,c,d,e,f,g,h,i,j) => { return a+b; }\n".repeat(50)
35 36 37
}

function CommaSepExpressionListShortSetup() {
38
  code = "let a;\n" + "a = (a,1)\n".repeat(50)
39 40 41
}

function CommaSepExpressionListLongSetup() {
42
  code = "let a; let b; let c;\n" + "a = (a,2,3,4,5,b,c,1,7,1)\n".repeat(50)
43 44 45 46
}

function CommaSepExpressionListLateSetup() {
  code = "let a; let b; let c; let d; let e; let f; let g; let h; let i;\n"
47
    + "a = (a,b,c,d,e,f,g,h,i,1)\n".repeat(50)
48 49 50 51
}

function FakeArrowFunctionSetup() {
  code = "let a; let b; let c; let d; let e; let f; let g; let h; let i; let j;\n"
52
    + "a = (a,b,c,d,e,f,g,h,i,j)\n".repeat(50)
53 54 55 56 57 58 59 60
}

function Run() {
  if (code == undefined) {
    throw new Error("No test data");
  }
  eval(code);
}