Code Review Question 58549 (v4)

Revision 4 of this benchmark created on


Description

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="time-progress"></div>
<div id="time-remaining"></div>

Setup

duration = 5000;
    function digitize(n) {
        return n > 9 ? "" + n : "0" + n;
    }
    function secondsToHMS(seconds) {
        var numhours = digitize(Math.floor(((seconds % 31536000) % 86400) / 3600));
        var numminutes = digitize(Math.floor((((seconds % 31536000) % 86400) % 3600) / 60));
        var numseconds = digitize(Math.floor((((seconds % 31536000) % 86400) % 3600) % 60));
        return numhours + ":" + numminutes + ":" + numseconds;
    }
    
    timeProgress_58549 = $("#time-progress");
    timeRemaining_58549 = $("#time-remaining");
    function processTime_58549(currentTime) {
        var value = (100 / duration) * currentTime;
        var progressHMS = secondsToHMS(currentTime);
        var remainingHMS = "-" + secondsToHMS(duration - currentTime);
        timeProgress_58549.html(progressHMS);
        timeRemaining_58549.html(remainingHMS);
    }
    
    var timeProgress_58562 = document.createTextNode("");
    document.getElementById('time-progress').appendChild(timeProgress_58562);
    var timeRemaining_58562 = document.createTextNode("");
    document.getElementById('time-progress').appendChild(timeRemaining_58562);
    function processTime_58562(currentTime) {
        var value = (100 / duration) * currentTime;
        var progressHMS = secondsToHMS(currentTime);
        var remainingHMS = "-" + secondsToHMS(duration - currentTime);
        timeProgress_58562.data = progressHMS;
        timeRemaining_58562.data = progressHMS;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
OP
processTime_58549(duration / 2);
ready
Dagg
processTime_58562(duration / 2);
ready

Revisions

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