in reply to how long does for(1..$n) take?

Now, if only there were a builtin function that would cause the script to pause for a specified number of seconds ... like, say, this one?

=)

As far as the general question goes, timing with a for loop seems subject to system load as well as the more obvious things (like available RAM, processor type and speed, etc.). Even if you benchmarked it, how could you ever rely on the system being in the same state as it was when you benchmarked it?

Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Replies are listed 'Best First'.
(jptxs) Re: how long does for(1..$n) take?
by jptxs (Curate) on Feb 16, 2001 at 04:52 UTC
    sleep won't do it. I want it to actually *do* something for that period of time. Actually, i want it to spike CPU for that period of time, so sleep is quite unsuited to that =)
    "A man's maturity -- consists in having found again the seriousness one had as a child, at play." --Nietzsche
      alarm(), as suggested earlier, will work just fine. It sounds as though you are building some sort of test suite, though.

      In that case, to keep it modular, it may make sense to fork a child and have the parent sleep(60) then kill the child.

      Update: This also has the advantage of returning all the memory back to the OS after your malloc() fest. TIMTOWTDI