replace vs string concat
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
charLimitErrorMsg = 'Oops! The personal message can only be %l characters long. Please shorten your message.';
msgStart = 'Oops! The personal message can only be ';
msgEnd = 'characters long. Please shorten your message.';
rx = /%l/;
repStr = '57';
repInt = 57;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Replace with int |
|
pending… |
Replace with str |
|
pending… |
String concat w/ int |
|
pending… |
String concat with str |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments