Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
String Repeatify
(version: 0)
Comparing performance of:
1 vs 2 vs 3 vs 4
Created:
8 years ago
by:
Guest
Jump to the latest result
Tests:
1
String.prototype.repeatify = function(numTimes) { let result = this; for (let i = 0; i < numTimes - 1; i++) { result += this; } return result; }; 'test'.repeatify(100);
2
String.prototype.repeatify = function(numTimes) { return new Array(numTimes + 1).join(this); }; 'test'.repeatify(100);
3
String.prototype.repeatify = function(numTimes) { return new Array(numTimes).fill(this).join(''); }; 'test'.repeatify(100);
4
String.prototype.repeatify = function(numTimes) { var strArray = [this]; for (var i = 0; i < numTimes - 1; i++) { strArray.push(this); } return strArray.join(''); }; 'test'.repeatify(100);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
1
2
3
4
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
stringify by concatenating or regex replacement or array joining
Trimming leading/trailing characters
Trimming multiple leading/trailing characters
Trimming leading/trailing characters from string
Trimming leading/trailing characters again
Comments
Confirm delete:
Do you really want to delete benchmark?