Search notes:

Browser Object Model: console.time() / timeEnd()

console.time(timerName) starts a timer that is named by timerName. The timer ends with a call to console.timeEnd(timerName) and the duration will be written into the console window.
<html>
<head>
  <meta charset="utf8">
  <title>console.time</title>

<script type="text/JavaScript">

var out;

function bar(i) {

  console.time('t_bar');

  for (var j=0; j < i*3; j++) {
    console.log('j=' + j);
  }

  console.timeEnd('t_bar');
}

function foo() {

  console.time('t_foo');

  for (var i=0; i<3; i++) {
    console.log('i='+i);
    bar(i);
  }

  console.timeEnd('t_foo');
}

function main() {
  out = document.getElementById('out');
  foo();
}


</script>
</head>
<body onload='main()'>

  <div id='out'> </div>

</body>
</html>
Github repository Browser-Object-Model, path: /console/time.html

Output into console window

See also

The console object of the browser object model

Index