Javascript console.timeEnd() Method with label

Introduction

Using the label parameter:

Press F12 on your keyboard to view the result in the console view.

Time the number of milliseconds it takes to perform a for-loop a hundred thousand times.

Make sure you use the same label when calling the console.timeEnd() method.

View in separate window

<!DOCTYPE html>
<html>
<body>
<script>
var i;/*from  w  ww  .j av a 2  s .  c om*/
console.time("test1");
for (i = 0; i < 100000; i++) {
  // some code
}
console.timeEnd("test1");

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



PreviousNext

Related