Pad perf

Benchmark created by Anony Anonymous on


Preparation HTML

<script>
  var h = 5;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Concatenation
let str = h.toString();
while (str.length < 5) {
  str = "0" + str;
}
ready
Array
let needToAdd = Math.max(0, 5 - h.length);
var pad = new Array(needToAdd + 1).join("0");
return pad + h;
ready

Revisions

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

  • Revision 1: published by Anony Anonymous on