Comment #2 on issue 4384 by bugdro...@chromium.org:
String.prototype.startsWith is slow
https://code.google.com/p/v8/issues/detail?id=4384#c2
The following revision refers to this bug:
https://chromium.googlesource.com/v8/v8.git/+/d42920ce06853d2982f52a9023ad4652f09a9277
commit d42920ce06853d2982f52a9023ad4652f09a9277
Author: karl <k...@skomski.com>
Date: Fri Sep 04 21:34:23 2015
[es6] Use SubString in String{Starts,Ends}With
Much faster and constant than always searching the whole string
````
var allCodePoints = [];
for (var i = 0; i < 65536; i++) allCodePoints[i] = i;
var allCharsString = String.fromCharCode.apply(String, allCodePoints);
function bench(search) {
var counter = 0;
print(search + " found at " + allCharsString.startsWith(search));
var start = Date.now();
while (counter++ < 5000000) {
allCharsString.startsWith(search);
}
var end = Date.now();
print(end - start);
return counter;
}
print("single character");
bench("\u0000");
bench("\u0050");
bench("\u1000");
````
OLD
single character
found at true
374
P found at false
559
က found at false
13492
NEW
single character
found at true
261
P found at false
146
က found at false
146
BUG=v8:4384
LOG=N
Review URL: https://codereview.chromium.org/1321853006
Cr-Commit-Position: refs/heads/master@{#30599}
[modify]
http://crrev.com/d42920ce06853d2982f52a9023ad4652f09a9277/src/string.js
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.