// Functions that produce fixed results and are called multiple times in the page
function check() {
//Simulation time-consuming operation
var begin = (); //Added by ECMAScript5, if it is not supported, please change it to +new Date();
var ONE_SECOND = 1000,
result = false;
while(true) {
if(() - begin >= ONE_SECOND){
result = true;
break;
}
}
//Rewrite the function and return the result directly
check = function() {
return result;
}
return result;
}
var firstBegin = ();
check(); //The first function call
var firstEnd = ();
check(); //The second function call
var secondEnd = ();
("The first function takes time:" + (firstEnd - firstBegin) + "ms.");
("Second function time consuming:" + (secondEnd - firstEnd) + "ms.");