repeat-string-latest

Benchmark created by Onury on


Setup

var count = 1000;
    var string = 'xxx-';

Test runner

Ready to run.

Testing in
TestOps/sec
while-loop-A
if (count < 1) {
  return '';
}
var repeated = '';
while (count > 0) {
  if (count & 1) {
    repeated += string;
  }
  count >>= 1;
  string += string;
}
return repeated;
ready
while-loop-B
if (count < 1) {
  return '';
}
var c = 0,
  repeated = '';
while (count > c) {
  repeated += string;
  c++;
}
return repeated;
ready
Array-join
return new Array(count + 1).join(string);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Onury on