2018-02-28 11:38:57 +00:00
|
|
|
// 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.
|
|
|
|
|
2018-05-24 14:26:15 +00:00
|
|
|
const subjects = [
|
|
|
|
'abcde', '123456', 'aqwsde', 'nbvveqxu', 'f03ks-120-3;jfkm;ajp3f',
|
|
|
|
'sd-93u498thikefnow8y3-0rh1nalksfnwo8y3t19-3r8hoiefnw'
|
|
|
|
];
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropFirstSlice', 5, StringDropFirstSlice);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
function StringDropFirstSubstr() {
|
|
|
|
var sum = "";
|
|
|
|
|
|
|
|
for (var j = 0; j < subjects.length; ++j) {
|
|
|
|
let s = subjects[j];
|
|
|
|
sum += s.substr(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropFirstSubstr', 5, StringDropFirstSubstr);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
function StringDropFirstSubstring() {
|
|
|
|
var sum = "";
|
|
|
|
|
|
|
|
for (var j = 0; j < subjects.length; ++j) {
|
|
|
|
let s = subjects[j];
|
|
|
|
sum += s.substring(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropFirstSubstring', 5, StringDropFirstSubstring);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringTakeFirstSlice', 5, StringTakeFirstSlice);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
function StringTakeFirstSubstr() {
|
|
|
|
var sum = "";
|
|
|
|
|
|
|
|
for (var j = 0; j < subjects.length; ++j) {
|
|
|
|
let s = subjects[j];
|
|
|
|
sum += s.substr(0,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringTakeFirstSubstr', 5, StringTakeFirstSubstr);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
function StringTakeFirstSubstring() {
|
|
|
|
var sum = "";
|
|
|
|
|
|
|
|
for (var j = 0; j < subjects.length; ++j) {
|
|
|
|
let s = subjects[j];
|
|
|
|
sum += s.substring(0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringTakeFirstSubstring', 5, StringTakeFirstSubstring);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropLastSlice', 5, StringDropLastSlice);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropLastSubstr', 5, StringDropLastSubstr);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropLastSubstring', 5, StringDropLastSubstring);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringTakeLastSlice', 5, StringTakeLastSlice);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
function StringTakeLastSubstr() {
|
|
|
|
var sum = "";
|
|
|
|
|
|
|
|
for (var j = 0; j < subjects.length; ++j) {
|
|
|
|
let s = subjects[j];
|
|
|
|
sum += s.substr(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringTakeLastSubstr', 5, StringTakeLastSubstr);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringTakeLastSubstring', 5, StringTakeLastSubstring);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropFirstSlice', 5, StringDropFirstSlice);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropFirstSubstr', 5, StringDropFirstSubstr);
|
2018-02-28 11:38:57 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-05-24 14:26:15 +00:00
|
|
|
createSuiteWithWarmup('StringDropFirstSubstring', 5, StringDropFirstSubstring);
|