我正在尝试查找代码的执行时间,但它无法正常工作

时间:2017-03-25 14:50:02

标签: javascript

我正在尝试测试嵌入到html中的脚本需要多长时间以及执行外部javascript需要多长时间。

我在尝试:

更新:

<!DOCTYPE html>
<html>
<body>

<h1>External JavaScript</h1>

<p id="demo">A Paragraph.</p>

<button type="button" onclick="myFunction()">Try it</button>

<p>(myFunction is stored in an external file called "myScript.js")</p>

<script src="myScript.js"></script>

<script>

var t0 = performance.now();
myFunction();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")

</script>

</body>
</html>

没有输出时间。

1 个答案:

答案 0 :(得分:0)

您可以使用jsperf来测试脚本的性能,并将其与其他节点或使用节点benchmark测试进行比较。

相关问题