Is it reasonable to expect this AngularJS function to perform well? I have this function which is associated with a timer that I'm creating in AngualarJS. Should I be concerned about the function being able to execute quickly enough for the timer to be accurate.

$scope.start = function() {
    if($scope.counting === true) return false;
    $scope.counting = true;
    $scope.counter = $timeout(function updateCount() {
        $scope.count++;
        $scope.hh = Math.floor($scope.count / 360000);
        $scope.mm = Math.floor(($scope.count - ($scope.hh * 360000)) / 6000);
        $scope.ss = Math.floor(($scope.count - ($scope.hh * 360000) - ($scope.mm * 6000)) / 100);
        $scope.ms = Math.floor($scope.count - ($scope.hh * 360000) - ($scope.mm * 6000) - ($scope.ss * 100));
        $scope.counter = $timeout(updateCount, 10);
    }, 10);
};
After digging around a bit, it seems the most appropriate approach for this is to create a kind of "fix" for latency resulting from CPU time that will quickly cause inaccuracies in a javascript timer. I wrote the below to demonstrate. As you can see, the setTimeout named timer1 includes a check based on the difference between the start Date object and an updated Date object. Using this value, we can calculate (with better, not perfect, accuracy) how off our incrementing time is. The setTimeout named timer2 does not include this check and, as you will see, the latency begins to accumulate.

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Accurate Timer Test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;&lt;label&gt;Corrected Example:&lt;/label&gt;&lt;input type="text" value="0" name="correct" id="correct" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;label&gt;Latency Example:&lt;/label&gt;&lt;input type="text" value="0" name="latency" id="latency" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="#" id="start"&gt;Start&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="#" id="stop"&gt;Stop&lt;/a&gt;&lt;/p&gt;
&lt;script type="text/javascript"&gt;
    window.onload = function() {
        var timerTest = new TimerTest(),
            correct = document.getElementById("correct"),
            latency = document.getElementById("latency");

        document.getElementById("start").addEventListener("click", function(evt) {
            timerTest.start();
            return false;
        });

        document.getElementById("stop").addEventListener("click", function(evt) {
            timerTest.stop();
            return false;
        });
    };

    var TimerTest = function() {
        var _this = this,
            timer1 = false,
            timer2 = false,
            start = 0,
            time1 = 0,
            time2 = 0,
            elapsed1 = 0,
            elapsed2 = 0,
            diff = 0;

        _this.start = function() {
            start = new Date().getTime();
            timer1 = setTimeout(_this.updateTimer1, 100);
            timer2 = setTimeout(_this.updateTimer2, 100);
        };

        _this.stop = function() {
            clearTimeout(timer1);
            clearTimeout(timer2);
            timer1 = false;
            timer2 = false;

        }

        _this.updateTimer1 = function() {
            time1 += 100;
            elapsed1 = Math.floor(time1 / 100) / 10;
            if(Math.round(elapsed1) == elapsed1) elapsed1 += '.0';
            correct.value = elapsed1;
            diff = (new Date().getTime() - start) - time1;
            timer1 = setTimeout(_this.updateTimer1, 100 - diff);
        };

        _this.updateTimer2 = function() {
            time2 += 100;
            elapsed2 = Math.floor(time2 / 100) / 10;
            if(Math.round(elapsed2) == elapsed2) elapsed2 += '.0';
            latency.value = elapsed2;
            timer2 = setTimeout(_this.updateTimer2, 100);
        }

        return _this;
    };
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;