How to measure code execution time in VBScript or JavaScript?

前端 未结 7 1619
野趣味
野趣味 2020-12-06 05:23

What is a good way to measure code execution time in VBScript?

Or failing that how to do it in JavaScript?

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 05:55

    For JavaScript, I would recommend you to use a profiler, like the one built-in in Firebug:


    (source: getfirebug.com)

    Other alternatives can be the one included with Google Chrome, or IE8

    If you want to do it programmatically, you could use Date objects to get a time difference:

    var startTime = new Date();
    // ...
    // ...
    var endTime = new Date();
    var delta = endTime - startTime; // difference in milliseconds
    

提交回复
热议问题