Commit d354feb6 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[parser|js-perf-test] Add js-perf tests for parsing / scanning.

These will tight-loop scanning primitives.

BUG=v8:6092

Change-Id: I9bf0f1952755bbede3c545c45fe2c4a210548171
Reviewed-on: https://chromium-review.googlesource.com/647526Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47788}
parent 1bf56342
...@@ -612,6 +612,18 @@ ...@@ -612,6 +612,18 @@
{"name": "Runtime.evaluate(String16Cstor)"}, {"name": "Runtime.evaluate(String16Cstor)"},
{"name": "Debugger.getPossibleBreakpoints"} {"name": "Debugger.getPossibleBreakpoints"}
] ]
},
{
"name": "Parsing",
"path": ["Parsing"],
"main": "run.js",
"resources": [ "comments.js"],
"results_regexp": "^%s\\-Parsing\\(Score\\): (.+)$",
"tests": [
{"name": "OneLineComment"},
{"name": "OneLineComments"},
{"name": "MultiLineComment"}
]
} }
] ]
} }
// 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.
const iterations = 100;
// Each benchmark.run is surrounded by a loop of 100. To generate the right
// amount of test cases, we just need to know this constant.
const fixed_iterations_by_runner = 100;
new BenchmarkSuite('OneLineComment', [1000], [
new Benchmark('OneLineComment', false, true, iterations, Run, OneLineCommentSetup)
]);
new BenchmarkSuite('OneLineComments', [1000], [
new Benchmark('OneLineComments', false, true, iterations, Run, OneLineCommentsSetup)
]);
new BenchmarkSuite('MultiLineComment', [1000], [
new Benchmark('MultiLineComment', false, true, iterations, Run, MultiLineCommentSetup)
]);
let codes;
let ix;
// Functions generating the code snippets which the actual test will eval. The
// snippets need to be different for each iteration, so that we won't hit the
// compilation cache.
function OneLineCommentSetup() {
codes = [];
ix = 0;
for (let i = 0; i < iterations * fixed_iterations_by_runner; ++i) {
let code = "//" + " This is a comment... ".repeat(600) + i;
codes.push(code);
}
}
function OneLineCommentsSetup() {
codes = [];
ix = 0;
for (let i = 0; i < iterations * fixed_iterations_by_runner; ++i) {
let code = "// This is a comment.\n".repeat(600) + "\n//" + i;
codes.push(code);
}
}
function MultiLineCommentSetup() {
codes = [];
ix = 0;
for (let i = 0; i < iterations * fixed_iterations_by_runner; ++i) {
let code = "/*" + " This is a comment... ".repeat(600) + "*/" + i;
codes.push(code);
}
}
function Run() {
if (ix >= codes.length) {
throw new Error("Not enough test data");
}
eval(codes[ix]);
++ix;
}
// 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.
load('../base.js');
load('comments.js');
var success = true;
function PrintResult(name, result) {
print(name + '-Parsing(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 });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment