v8/test/js-perf-test/Strings/string-split.js
Choongwoo Han c34562803e [string] Add a perf test for String.p.split
Bug: v8:7103
Change-Id: I86e208de38aad1d41c65d39b94996012efa1346b
Reviewed-on: https://chromium-review.googlesource.com/1045949
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53063}
2018-05-08 12:19:52 +00:00

82 lines
2.2 KiB
JavaScript

// 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.
new BenchmarkSuite('ShortSubjectEmptySeparator', [5], [
new Benchmark('ShortSubjectEmptySeparator', true, false, 0,
ShortSubjectEmptySeparator),
]);
new BenchmarkSuite('LongSubjectEmptySeparator', [1000], [
new Benchmark('LongSubjectEmptySeparator', true, false, 0,
LongSubjectEmptySeparator),
]);
new BenchmarkSuite('ShortTwoBytesSubjectEmptySeparator', [5], [
new Benchmark('ShortTwoBytesSubjectEmptySeparator', true, false, 0,
ShortTwoBytesSubjectEmptySeparator),
]);
new BenchmarkSuite('LongTwoBytesSubjectEmptySeparator', [1000], [
new Benchmark('LongTwoBytesSubjectEmptySeparator', true, false, 0,
LongTwoBytesSubjectEmptySeparator),
]);
new BenchmarkSuite('ShortSubject', [5], [
new Benchmark('ShortSubject', true, false, 0,
ShortSubject),
]);
new BenchmarkSuite('LongSubject', [1000], [
new Benchmark('LongSubject', true, false, 0,
LongSubject),
]);
new BenchmarkSuite('ShortTwoBytesSubject', [5], [
new Benchmark('ShortTwoBytesSubject', true, false, 0,
ShortTwoBytesSubject),
]);
new BenchmarkSuite('LongTwoBytesSubject', [1000], [
new Benchmark('LongTwoBytesSubject', true, false, 0,
LongTwoBytesSubject),
]);
const shortString = "ababaabcdeaaaaaab";
const shortTwoBytesString = "\u0429\u0428\u0428\u0429\u0429\u0429\u0428\u0429\u0429";
// Use Array.join to create a flat string
const longString = new Array(0x500).fill("abcde").join('');
const longTwoBytesString = new Array(0x500).fill("\u0427\u0428\u0429\u0430").join('');
function ShortSubjectEmptySeparator() {
shortString.split('');
}
function LongSubjectEmptySeparator() {
longString.split('');
}
function ShortTwoBytesSubjectEmptySeparator() {
shortTwoBytesString.split('');
}
function LongTwoBytesSubjectEmptySeparator() {
longTwoBytesString.split('');
}
function ShortSubject() {
shortString.split('a');
}
function LongSubject() {
longString.split('a');
}
function ShortTwoBytesSubject() {
shortTwoBytesString.split('\u0428');
}
function LongTwoBytesSubject() {
longTwoBytesString.split('\u0428');
}