Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,145 @@
// Copyright 2014 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('StringRepeat', [10], [
new Benchmark('StringRepeat', false, false, 0,
Repeat, RepeatSetup, RepeatTearDown),
]);
new BenchmarkSuite('StringStartsWith', [10], [
new Benchmark('StringStartsWith', false, false, 0,
StartsWith, WithSetup, WithTearDown),
]);
new BenchmarkSuite('StringEndsWith', [10], [
new Benchmark('StringEndsWith', false, false, 0,
EndsWith, WithSetup, WithTearDown),
]);
new BenchmarkSuite('StringIncludes', [10], [
new Benchmark('StringIncludes', false, false, 0,
Includes, IncludesSetup, WithTearDown),
]);
new BenchmarkSuite('StringFromCodePoint', [10000], [
new Benchmark('StringFromCodePoint', false, false, 0,
FromCodePoint, FromCodePointSetup, FromCodePointTearDown),
]);
new BenchmarkSuite('StringCodePointAt', [1000], [
new Benchmark('StringCodePointAt', false, false, 0,
CodePointAt, CodePointAtSetup, CodePointAtTearDown),
]);
new BenchmarkSuite('StringCodePointAtSum', [100000], [
new Benchmark('StringCodePointAtSum', false, true, 3,
CodePointAtSum, CodePointAtSumSetup),
]);
var result;
var stringRepeatSource = "abc";
function RepeatSetup() {
result = undefined;
}
function Repeat() {
result = stringRepeatSource.repeat(500);
}
function RepeatTearDown() {
var expected = "";
for (var i = 0; i < 1000; i++) {
expected += stringRepeatSource;
}
return result === expected;
}
var str;
var substr;
function WithSetup() {
str = "abc".repeat(500);
substr = "abc".repeat(200);
result = undefined;
}
function WithTearDown() {
return !!result;
}
function StartsWith() {
result = str.startsWith(substr);
}
function EndsWith() {
result = str.endsWith(substr);
}
function IncludesSetup() {
str = "def".repeat(100) + "abc".repeat(100) + "qqq".repeat(100);
substr = "abc".repeat(100);
}
function Includes() {
result = str.includes(substr);
}
var MAX_CODE_POINT = 0xFFFFF;
const K = 1024;
function FromCodePointSetup() {
result = new Array((MAX_CODE_POINT + 1) / K);
}
function FromCodePoint() {
for (var i = 0; i <= MAX_CODE_POINT; i += K) {
result[i] = String.fromCodePoint(i);
}
}
function FromCodePointTearDown() {
for (var i = 0; i <= MAX_CODE_POINT; i += K) {
if (i !== result[i].codePointAt(0)) return false;
}
return true;
}
var allCodePoints;
function CodePointAtSetup() {
allCodePoints = new Array((MAX_CODE_POINT + 1) / K);
for (var i = 0; i <= MAX_CODE_POINT; i += K) {
allCodePoints = String.fromCodePoint(i);
}
result = undefined;
}
function CodePointAt() {
result = 0;
for (var i = 0; i <= MAX_CODE_POINT; i += K) {
result += allCodePoints.codePointAt(i);
}
}
function CodePointAtTearDown() {
return result === (MAX_CODE_POINT / K) * ((MAX_CODE_POINT / K) + 1) / 2;
}
var payload;
function CodePointAtSumSetup() {
payload = "abcdefghijklmnopqrstuvwxyz";
for(var j = 0; j < 16; ++j) payload += payload;
}
function CodePointAtSum() {
var c = 0;
for(j=payload.length-1; j >=0; --j) c+=payload.charCodeAt(j);
return c;
}

View File

@ -0,0 +1,25 @@
// Copyright 2014 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.
d8.file.execute('../base.js');
d8.file.execute(arguments[0] + '.js');
var success = true;
function PrintResult(name, result) {
print(name + '-Strings(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 });

View File

@ -0,0 +1,36 @@
// 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.
new BenchmarkSuite('StringIndexOfConstant', [5], [
new Benchmark('StringIndexOfConstant', true, false, 0,
StringIndexOfConstant),
]);
new BenchmarkSuite('StringIndexOfNonConstant', [5], [
new Benchmark('StringIndexOfNonConstant', true, false, 0,
StringIndexOfNonConstant),
]);
const subject = "aaaaaaaaaaaaaaaab";
const searches = ['a', 'b', 'c'];
function StringIndexOfConstant() {
var sum = 0;
for (var j = 0; j < searches.length; ++j) {
sum += subject.indexOf("" + searches[j]);
}
return sum;
}
function StringIndexOfNonConstant() {
var sum = 0;
for (var j = 0; j < searches.length; ++j) {
sum += subject.indexOf(searches[j]);
}
return sum;
}

View File

@ -0,0 +1,19 @@
// 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('StringLocaleCompare', [1000000], [
new Benchmark('StringLocaleCompare', false, false, 0,
StringLocaleCompare),
]);
function StringLocaleCompare() {
var array = ["XYZ", "mno", "abc", "EFG", "ijk", "123", "tuv", "234", "efg"];
var sum = 0;
for (var j = 0; j < array.length; ++j) {
sum += "fox".localeCompare(array[j]);
}
return sum;
}

View File

@ -0,0 +1,77 @@
// 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 Internalize(s) {
return Object.keys({[s]:0})[0];
}
const string = Internalize('a'.repeat(100));
let pattern;
let result;
const setupString = () => pattern = '.';
const setupRegExp = () => pattern = /./g;
const setupZeroWidth = () => pattern = /(?:)/g;
const setupZeroWidthUnicode = () => pattern = /(?:)/gu;
function benchIteratorCreation() {
result = string.matchAll(pattern);
}
function benchBuiltin() {
for (const match of string.matchAll(pattern)) {
result = match[0];
}
}
function benchManualString() {
let regexp = new RegExp(pattern, 'g');
let match;
while ((match = regexp.exec(string)) !== null) {
result = match[0];
}
}
function benchManualRegExp() {
let match;
while ((match = pattern.exec(string)) !== null) {
result = match[0];
}
}
// Iterator Creation
new BenchmarkSuite('StringMatchAllBuiltinRegExpIteratorCreation', [20], [
new Benchmark('StringMatchAllBuiltinRegExpIteratorCreation', false, false, 0, benchIteratorCreation, setupRegExp)
]);
new BenchmarkSuite('StringMatchAllBuiltinStringIteratorCreation', [20], [
new Benchmark('StringMatchAllBuiltinStringIteratorCreation', false, false, 0, benchIteratorCreation, setupString)
]);
// String
new BenchmarkSuite('StringMatchAllBuiltinString', [20], [
new Benchmark('StringMatchAllBuiltinString', false, false, 0, benchBuiltin, setupString)
]);
new BenchmarkSuite('StringMatchAllManualString', [20], [
new Benchmark('StringMatchAllManualString', false, false, 0, benchManualString, setupString)
]);
// RegExp
new BenchmarkSuite('StringMatchAllBuiltinRegExp', [20], [
new Benchmark('StringMatchAllBuiltinRegExp', false, false, 0, benchBuiltin, setupRegExp)
]);
new BenchmarkSuite('StringMatchAllManualRegExp', [20], [
new Benchmark('StringMatchAllManualRegExp', false, false, 0, benchManualRegExp, setupRegExp)
]);
// Zero width
new BenchmarkSuite('StringMatchAllBuiltinZeroWidth', [20], [
new Benchmark('StringMatchAllBuiltinZeroWidth', false, false, 0, benchBuiltin, setupZeroWidth)
]);
new BenchmarkSuite('StringMatchAllBuiltinZeroWidthUnicode', [20], [
new Benchmark('StringMatchAllBuiltinZeroWidthUnicode', false, false, 0, benchBuiltin, setupZeroWidthUnicode)
]);
})();

View File

@ -0,0 +1,38 @@
// Copyright 2019 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('StringNormalize', [5], [
new Benchmark('StringNormalize', false, false, 0,
StringNormalize),
]);
new BenchmarkSuite('StringNormalizeNFD', [5], [
new Benchmark('StringNormalizeNFD', false, false, 0,
StringNormalizeNFD),
]);
new BenchmarkSuite('StringNormalizeNFKC', [5], [
new Benchmark('StringNormalizeNFKC', false, false, 0,
StringNormalizeNFKC),
]);
new BenchmarkSuite('StringNormalizeNFKD', [5], [
new Benchmark('StringNormalizeNFKD', false, false, 0,
StringNormalizeNFKD),
]);
const shortString = "àèìòùáéíóúäëïöüÿâêîôûãõñ";
function StringNormalize() {
return shortString.normalize();
}
function StringNormalizeNFD() {
return shortString.normalize("NFD");
}
function StringNormalizeNFKC() {
return shortString.normalize("NFKC");
}
function StringNormalizeNFKD() {
return shortString.normalize("NFKD");
}

View File

@ -0,0 +1,81 @@
// 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');
}

View File

@ -0,0 +1,47 @@
// 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 createSuiteWithWarmup( name, count, fn) {
new BenchmarkSuite(name, [count], [
new Benchmark(name, true, false, 0, fn),
]);
}
const inputs = [
'I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\u2603\uD83D\uDCA9\uFFFD',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Integer eu augue suscipit, accumsan ipsum nec, sagittis sem.',
'In vitae pellentesque dolor. Curabitur leo nunc, luctus vitae',
'risus eget, fermentum hendrerit justo.',
];
const first = 'I';
function helper(fn) {
let sum = 0;
for (const input of inputs) {
sum += fn(input);
}
return sum;
}
function startsWith(string) {
return string.startsWith(first);
}
function startsIndex(string) {
return string[0] === first;
}
function endsWith(string) {
return string.endsWith(first);
}
function endsIndex(string) {
return string[string.length - 1] === first;
}
createSuiteWithWarmup('startsWith', 1, () => helper(startsWith));
createSuiteWithWarmup('startsIndex', 1, () => helper(startsIndex));
createSuiteWithWarmup('endsWith', 1, () => helper(endsWith));
createSuiteWithWarmup('endsIndex', 1, () => helper(endsIndex));

View File

@ -0,0 +1,78 @@
// Copyright 2019 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 createSuite(name, count, fn) {
new BenchmarkSuite(name, [count], [new Benchmark(name, true, false, 0, fn)]);
}
const inputs = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Integer eu augue suscipit, accumsan ipsum nec, sagittis sem.',
'In vitae pellentesque dolor. Curabitur leo nunc, luctus vitae',
'risus eget, fermentum hendrerit justo.',
'hello'.repeat(1024),
'h',
''
];
const firsts = ['I', 'Integer', 'Lorem', 'risus', 'hello'];
function simpleHelper() {
let sum = 0;
for (const input of inputs) {
for (const first of firsts) {
sum += input.startsWith(first);
}
}
return sum;
}
function consInputHelper() {
let sum = 0;
for (const inputOne of inputs) {
for (const inputTwo of inputs) {
for (const first of firsts) {
// Skip if the length is too small for %ConstructConsString
if (inputOne.length + inputTwo.length < 13) break;
sum += %ConstructConsString(inputOne, inputTwo).startsWith(first);
}
}
}
return sum;
}
function consFirstHelper() {
let sum = 0;
for (const input of inputs) {
for (const firstOne of firsts) {
for (const firstTwo of firsts) {
// Skip if the length is too small for %ConstructConsString
if (firstOne.length + firstTwo.length < 13) break;
sum += input.startsWith(%ConstructConsString(firstOne, firstTwo));
}
}
}
return sum;
}
function doubleConsHelper() {
let sum = 0;
for (const inputOne of inputs) {
for (const inputTwo of inputs) {
for (const firstOne of firsts) {
for (const firstTwo of firsts) {
// Skip if the length is too small for %ConstructConsString
if (inputOne.length + inputTwo.length < 13 || firstOne.length + firstTwo.length) break;
sum += % ConstructConsString(inputOne, inputTwo).startsWith(
% ConstructConsString(firstOne, firstTwo)
);
}
}
}
}
}
createSuite('DirectStringsDirectSearch', 1000, simpleHelper);
createSuite('ConsStringsDirectSearch', 1000, consInputHelper);
createSuite('DirectStringsConsSearch', 1000, consFirstHelper);
createSuite('ConsStringsConsSearch', 1000, doubleConsHelper);

View File

@ -0,0 +1,44 @@
// 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 input = 'äϠ<C3A4>𝌆 Lorem ipsum test test';
function helper(fn) {
var sum = 0;
for (var i = 0; i < input.length; i++) {
sum += fn(input, i, i);
}
return sum;
}
function charCodeAt(str, i) {
return str.charCodeAt(i) === 116;
}
function charCodeAtBoth(str, i, j) {
return str.charCodeAt(j) == str.charCodeAt(i);
}
function charAt(str, i) {
return 't' == str.charAt(i);
}
function charAtNever(str, i) {
return '𝌆' == str.charAt(i);
}
function charAtBoth(str, i, j) {
return str.charAt(j) == str.charAt(i);
}
function stringIndex(str, i) {
return str[i] === 't';
}
createSuiteWithWarmup('charCodeAt_const', 1, () => helper(charCodeAt));
createSuiteWithWarmup('charCodeAt_both', 1, () => helper(charCodeAtBoth));
createSuiteWithWarmup('charAt_const', 1, () => helper(charAt));
createSuiteWithWarmup('charAt_never', 1, () => helper(charAtNever));
createSuiteWithWarmup('charAt_both', 1, () => helper(charAtBoth));
createSuiteWithWarmup('stringIndex_const', 1, () => helper(stringIndex));

View File

@ -0,0 +1,129 @@
// 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.
new BenchmarkSuite('StringCharCodeAtConstant', [3], [
new Benchmark('StringCharCodeAtConstant', true, false, 0,
StringCharCodeAtConstant),
]);
new BenchmarkSuite('StringCharCodeAtNonConstant', [3], [
new Benchmark('StringCharCodeAtNonConstant', true, false, 0,
StringCharCodeAtNonConstant),
]);
new BenchmarkSuite('StringCharCodeAtConstantInbounds', [3], [
new Benchmark('StringCharCodeAtConstantInbounds', true, false, 0,
StringCharCodeAtConstantInbounds),
]);
new BenchmarkSuite('StringCharCodeAtNonConstantInbounds', [3], [
new Benchmark('StringCharCodeAtNonConstantInbounds', true, false, 0,
StringCharCodeAtNonConstantInbounds),
]);
const string = "qweruiplkjhgfdsazxccvbnm";
const indices = [1, 13, 32, 100, "xx"];
const indicesInbounds = [1, 7, 13, 17, "xx"];
function StringCharCodeAtConstant() {
var sum = 0;
for (var j = 0; j < indices.length - 1; ++j) {
sum += string.charCodeAt(indices[j] | 0);
}
return sum;
}
function StringCharCodeAtNonConstant() {
var sum = 0;
for (var j = 0; j < indices.length - 1; ++j) {
sum += string.charCodeAt(indices[j]);
}
return sum;
}
function StringCharCodeAtConstantInbounds() {
var sum = 0;
for (var j = 0; j < indicesInbounds.length - 1; ++j) {
sum += string.charCodeAt(indicesInbounds[j] | 0);
}
return sum;
}
function StringCharCodeAtNonConstantInbounds() {
var sum = 0;
for (var j = 0; j < indicesInbounds.length - 1; ++j) {
sum += string.charCodeAt(indicesInbounds[j]);
}
return sum;
}
new BenchmarkSuite('StringCodePointAtConstant', [3], [
new Benchmark('StringCodePointAtConstant', true, false, 0,
StringCodePointAtConstant),
]);
new BenchmarkSuite('StringCodePointAtNonConstant', [3], [
new Benchmark('StringCodePointAtNonConstant', true, false, 0,
StringCodePointAtNonConstant),
]);
new BenchmarkSuite('StringCodePointAtConstantInbounds', [3], [
new Benchmark('StringCodePointAtConstantInbounds', true, false, 0,
StringCodePointAtConstantInbounds),
]);
new BenchmarkSuite('StringCodePointAtNonConstantInbounds', [3], [
new Benchmark('StringCodePointAtNonConstantInbounds', true, false, 0,
StringCodePointAtNonConstantInbounds),
]);
const unicode_string = "qweräϠ<C3A4>𝌆krefdäϠ<C3A4>𝌆ccäϠ<C3A4>𝌆";
function StringCodePointAtConstant() {
var sum = 0;
for (var j = 0; j < indices.length - 1; ++j) {
sum += unicode_string.codePointAt(indices[j] | 0);
}
return sum;
}
function StringCodePointAtNonConstant() {
var sum = 0;
for (var j = 0; j < indices.length - 1; ++j) {
sum += unicode_string.codePointAt(indices[j]);
}
return sum;
}
function StringCodePointAtConstantInbounds() {
var sum = 0;
for (var j = 0; j < indicesInbounds.length - 1; ++j) {
sum += unicode_string.codePointAt(indicesInbounds[j] | 0);
}
return sum;
}
function StringCodePointAtNonConstantInbounds() {
var sum = 0;
for (var j = 0; j < indicesInbounds.length - 1; ++j) {
sum += unicode_string.codePointAt(indicesInbounds[j]);
}
return sum;
}

View File

@ -0,0 +1,198 @@
// 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 subjects = [
'abcde', '123456', 'aqwsde', 'nbvveqxu', 'f03ks-120-3;jfkm;ajp3f',
'sd-93u498thikefnow8y3-0rh1nalksfnwo8y3t19-3r8hoiefnw'
];
// Drop first element.
function StringDropFirstSlice() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.slice(1);
}
return sum;
}
createSuiteWithWarmup('StringDropFirstSlice', 5, StringDropFirstSlice);
function StringDropFirstSubstr() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substr(1);
}
return sum;
}
createSuiteWithWarmup('StringDropFirstSubstr', 5, StringDropFirstSubstr);
function StringDropFirstSubstring() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substring(1);
}
return sum;
}
createSuiteWithWarmup('StringDropFirstSubstring', 5, StringDropFirstSubstring);
// Take first element.
function StringTakeFirstSlice() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.slice(0,1);
}
return sum;
}
createSuiteWithWarmup('StringTakeFirstSlice', 5, StringTakeFirstSlice);
function StringTakeFirstSubstr() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substr(0,1);
}
return sum;
}
createSuiteWithWarmup('StringTakeFirstSubstr', 5, StringTakeFirstSubstr);
function StringTakeFirstSubstring() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substring(0, 1);
}
return sum;
}
createSuiteWithWarmup('StringTakeFirstSubstring', 5, StringTakeFirstSubstring);
// Drop last element.
function StringDropLastSlice() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.slice(0, -1);
}
return sum;
}
createSuiteWithWarmup('StringDropLastSlice', 5, StringDropLastSlice);
function StringDropLastSubstr() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substr(0, s.length-1);
}
return sum;
}
createSuiteWithWarmup('StringDropLastSubstr', 5, StringDropLastSubstr);
function StringDropLastSubstring() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substring(0, s.length-1);
}
return sum;
}
createSuiteWithWarmup('StringDropLastSubstring', 5, StringDropLastSubstring);
// Take last element.
function StringTakeLastSlice() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.slice(-1);
}
return sum;
}
createSuiteWithWarmup('StringTakeLastSlice', 5, StringTakeLastSlice);
function StringTakeLastSubstr() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substr(-1);
}
return sum;
}
createSuiteWithWarmup('StringTakeLastSubstr', 5, StringTakeLastSubstr);
function StringTakeLastSubstring() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substring(s.length-1, s.length);
}
return sum;
}
createSuiteWithWarmup('StringTakeLastSubstring', 5, StringTakeLastSubstring);
// Drop first and last.
function StringDropFirstSlice() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.slice(1, -1);
}
return sum;
}
createSuiteWithWarmup('StringDropFirstSlice', 5, StringDropFirstSlice);
function StringDropFirstSubstr() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j]
sum += s.substr(1, s.length-2);
}
return sum;
}
createSuiteWithWarmup('StringDropFirstSubstr', 5, StringDropFirstSubstr);
function StringDropFirstSubstring() {
var sum = "";
for (var j = 0; j < subjects.length; ++j) {
let s = subjects[j];
sum += s.substring(1, s.length-1);
}
return sum;
}
createSuiteWithWarmup('StringDropFirstSubstring', 5, StringDropFirstSubstring);

View File

@ -0,0 +1,35 @@
// Copyright 2019 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('StringToLocaleUpperCaseTR', [5], [
new Benchmark('StringToLocaleUpperCaseTR', false, false, 0,
StringToLocaleUpperCaseTR)
]);
new BenchmarkSuite('StringToLocaleLowerCaseTR', [5], [
new Benchmark('StringToLocaleLowerCaseTR', false, false, 0,
StringToLocaleLowerCaseTR),
]);
new BenchmarkSuite('StringToLocaleUpperCase', [5], [
new Benchmark('StringToLocaleUpperCase', false, false, 0,
StringToLocaleUpperCase)
]);
new BenchmarkSuite('StringToLocaleLowerCase', [5], [
new Benchmark('StringToLocaleLowerCase', false, false, 0,
StringToLocaleLowerCase),
]);
var shortString = "Îñţérñåţîöñåļîžåţîöñ Ļöçåļîžåţîöñ החןןם שםוןמ Γρεεκ ισ φθν 一二三";
function StringToLocaleUpperCase() {
return shortString.toLocaleUpperCase();
}
function StringToLocaleLowerCase() {
return shortString.toLocaleLowerCase();
}
function StringToLocaleUpperCaseTR() {
return shortString.toLocaleUpperCase(["tr"]);
}
function StringToLocaleLowerCaseTR() {
return shortString.toLocaleLowerCase(["tr"]);
}