<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script type=" text/javascript">
function loop() {
for (var i = 0; i <= 1000000; ++i){
document.write("");
}
}
(function() {
var start = Date.now();
loop();
var end = Date.now();
var use = end - start;
document.write("loop()花费时间:" + use + "毫秒");
})();
</script>
<body>
</body>
</html>
//检查loop()运行时间
loop()花费时间:165毫秒