What is a good way to measure code execution time in VBScript?
Or failing that how to do it in JavaScript?
For VBScript you can use Timer:
StartTime = Timer()
EndTime = Timer()
Response.Write("Seconds to 2 decimal places: " & FormatNumber(EndTime - StartTime, 2))
Or ASP Profiler (that is for an ASP environment.)
For JavaScript you can use Date:
var start = new Date().getTime()
alert("Milliseconds: " + (new Date().getTime() - start))
Firebug also has a profiler for JavaScript.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With