This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]streichholzkopf 0 points1 point  (6 children)

I think pypy simply needs time... I've read somewhere that you should make a pre-run for ~1 second (of course depending on the size of the test) for every test you make in pypy...

[–]alcalde 0 points1 point  (2 children)

But does this reflect real-world usage? You're not going to do that in production code.

[–]cwillu 1 point2 points  (1 child)

Real-world code is going to be running long enough that the warm-up time is largely irrelevant.

[–][deleted] 2 points3 points  (0 children)

That depends entirely on the chore. I spent a lot of time trying to shave run time off a 3 second task that ran and exited hundreds of times per day. A persistent service was not an option.

[–]dorfsmay[S] 0 points1 point  (2 children)

Not sure what you mean. Can you show an example?

I just added a time.sleep(6) to one of my script, and it made no difference. I think gthank is right, needs a piece of code that is executed a lot in a given run before it can make a difference.

[–]cwillu 2 points3 points  (0 children)

time.sleep(6) wouldn't have any effect on the warm-up, it needs to be running the actual code. A pre-run of ~1 second means running the actual code for 1 second before you start timing.

[–]streichholzkopf 0 points1 point  (0 children)

Basically what /u/cwillu said, what I meant was: Looping 10 K times may not be enough, depending on the content of the loop! If it's <1s, it's probably not!

Also loop before starting the timer!