Jsp testing function running speed method, jsp function Running Speed

Source: Internet
Author: User

Jsp testing function running speed method, jsp function Running Speed

We usually need to optimize the function. The general approach is to get the time at the beginning, and then get the time at the end, and the time spent will be equal to the two times. Function running speed is basically millisecond-level.

The following functions are prepared for this purpose.

// Function time2stamp () {var d = new Date (); return Date. parse (d) + d. getMilliseconds ();}

Usage:

Var t1 = time2stamp (); // compare the DOM running speed of each browser. Var divs = document. getElementByTagName ("div"); var t2 = time2stamp (); alert ("Time consumed:" + (t2-t1) + "millisecond ");

New method:

Var time1 = new Date // compare the DOM running speed of each browser. Var divs = document. getElementByTagName ("div"); alert ("Time consumed:" + (new Date-time1) + "millisecond ");

Test the efficiency of various cycles. A slow loop like for... in will not happen!

<! Doctype html> 

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

Related Article

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.