By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,605 Members | 2,153 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,605 IT Pros & Developers. It's quick & easy.

Measuring time taken to run a script

P: n/a
I notice on
http://msdn.microsoft.com/library/de...dude100499.asp
that the writer has measured the time taken to run the script down to
the millisecond.

Does anyone know what tools he used to calculate these load times?
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Fabian" <la****@hotmail.com> wrote in message
news:bs************@ID-174912.news.uni-berlin.de...
I notice on [ ... ] that the writer has measured the
time taken to run the script down to the millisecond.

Does anyone know what tools he used to calculate these
load times?


Instances of the Date object, they do not produce millisecond values
with a precision of less than about 10 milliseconds (and that varies by
OS) so timing operations would usually involve repeating the operation
sufficiently often and then dividing the interval by the number of times
the operation was repeated. Possibly also calculating the overhead
involved in the actual testing, including the looping, and probably
repeating the tests to reduce the influence of background tasks on
multitasking OSs.

It probably doesn't make sense to talk of timing scripts (at least in an
event driven browser context), more likely functions or sets of (or
individual) operations.

I have found that a limiting factor in repeatedly executing the same
code in a loop is the browser's tendency to put up a dialog saying
something like "a script on this page is causing the browser to run
slowly", which renders any results meaningless. However, I tend to
increase the number of iterations of the tested code until that dialog
is reported (in the browsers that do so) and then drop back just under
that limit so the average timings are as representative as they can be.

The relative efficiency of various operations is often debated here so a
well-phrased groups.google.com search of c.l.j should turn up numerous
examples of test pages/scripts.

Richard.
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.