Script Preparation code:
AخA
 
var z = 3661;
var t;
Tests:
  • If and modulo array

     
    var y = [];
    if (z>3600){
        y.push(Math.floor(z/3600));
    }
    z%=3600;
    if (z>60){
        y.push(Math.floor(z/60));
    }
    z%=60;
    if (z>0){
        y.push(Math.floor(z));
    }
    t = y.join(":").replace(/\b(\d)\b/g,"0$1");
  • Ternary and slice concatenation

     
    t = ("0"+Math.floor(z/3600).toString()).slice(-2)+":"+("0"+Math.floor(z%3600/60).toString()).slice(-2)+":"+("0"+Math.floor(z%3600%60).toString()).slice(-2)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    If and modulo array
    Ternary and slice concatenation

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36
Chrome 53 on Windows
View result in a separate tab
Test name Executions per second
If and modulo array 549892.5 Ops/sec
Ternary and slice concatenation 628100.1 Ops/sec