var cache vs no cache
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var text = 'hello this is my name oh yeah',
result;
String.prototype.truncate = String.prototype.truncate || function (length, substitute, fullwords) {
return this.length > (length || 30) ? this.substr(0, (length || 30)).replace(/\s$/, '') + (substitute || '…') : this.toString();
};
String.prototype.truncate2 = String.prototype.truncate || function (length, substitute, fullwords) {
var length = length || 30;
return this.length > length ? this.substr(0, length).replace(/\s$/, '') + (substitute || '…') : this.toString();
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
cache |
|
pending… |
no cache |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments