Test HTML5 performance with setTimeout() - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

Test HTML5 performance with setTimeout()

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
var timestamp = (new Date()).getTime();
function run() {//from  w  w w  .j a  va  2 s  .  c  o  m
     var now = (new Date()).getTime();
     if( now - timestamp >= 1000 ) {
         console.log( 'tick' );
         timestamp = now;
     }
     setTimeout(run, 10);
}
run();

      </script>  
   </body>
</html>

Related Tutorials