substring test short haystack
JavaScript performance comparison
Preparation code
<script>
var str = "This is a simple test!";
var needle = "simple";
var r = new RegExp('simple');
var ri = new RegExp('simple', 'i');
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
regex |
|
pending… |
indexof |
|
pending… |
RegExp |
|
pending… |
Cached RegExp |
|
pending… |
regex case insensitive |
|
pending… |
indexOf case insensitive |
|
pending… |
RegExp case insensitive |
|
pending… |
cached RegExp case insensitive |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published
- Revision 2: published by regexp or indexof
- Revision 3: published
- Revision 4: published by Georgi Krustev
- Revision 7: published by lisukorin
- Revision 8: published
- Revision 9: published
0 comments