in reply to My program drags and then runs fast. Why?

As others have said, you're not giving much away...

...however one can speculate.

these are examples of forms of cacheing as suggested by GrandFather. It's also possible that:so much for speculation.

Mind you, you say that things are slow to start with, no matter whether the input you're querying with is 20 lines or 1 million lines... and no matter how many lines, it's very slow for the first 20% of them ? Everything I can think of I would expect to speed up either as more queries are made, or after a period related to the size of the data. Neither of these are proportional to the number of lines queries.

You're sure it's not data dependent ?

Long story, made short: yes one can imagine ways that a program along the lines you describe can speed up over time -- but more information is required to diagnose why in this case !

  • Comment on Re: My program drags and then runs fast. Why?

Replies are listed 'Best First'.
Re^2: My program drags and then runs fast. Why?
by apomatix (Novice) on Oct 13, 2008 at 11:56 UTC

    Thanks everyone for your suggestions. (I am the poster—thought I was logged in).

    I know that the data structure is static once it's loaded since I wrote the C library, and that the Perl script is parsing only one line of data at a time. That's why this is really confusing me.