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!