Measuring time taken to run a script

R

Richard Cornford

Fabian said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top