JS Benchmark test: Console.time and Console.timeend

Source: Internet
Author: User
Tags benchmark

The Console.time and Console.timeend methods allow developers to use in arbitrary code, and the result shown is the intermediate duration, in milliseconds. Because JavaScript performance is more and more important, it is useful for programmers to understand basic benchmarking techniques. One of the simplest benchmark tools is the console.time and console.timeend combination.

Console.time starts a timer. Instead, Console.timeend stops the timer and writes out the elapsed time:

Start Timer (Name=testforeach)
console.time (' Testforeach ');

// (... Perform certain tests, such as a ForEach loop

, etc.//end timer, get run time
console.timeend (' Testforeach ');

Testforeach:13636.634ms (direct display at console, run time)

The first parameter passed in is the name of the timer to differentiate/respond to situations where multiple timers are required at the same time. Call Console.timeend immediately prints out the run time, in MS (MS).

console.time/timeend provides a manual speed test method! In addition, in the JS field there are many advanced performance/benchmarking technology and tools.

Translator: Anchor Http://blog.csdn.net/renfufei

Translation time: April 30, 2016

Original Date: April 4, 2016

Original link: https://davidwalsh.name/console-time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.