[Python-Dev] Disabling cyclic GC in timeit module (original) (raw)

John Arbash Meinel john at arbash-meinel.com
Tue Oct 18 09:47:15 CEST 2011


-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

...

If you are only measuring json encoding of a few select pieces of data then it's a microbenchmark. If you are measuring the whole application (or a significant part of it) then I'm not sure timeit is the right tool for that.

Regards Antoine. When you're measuring how much time it takes to encode json, this is a microbenchmark and yet the time that timeit gives you is misleading, because it'll take different amount of time in your application. I guess my proposition would be to not disable gc by default and disable it when requested, but well, I guess I'll give up given the strong push against it. Cheers, fijal

True, but it is also heavily dependent on how much other data your application has in memory at the time. If your application has 1M objects in memory and then goes to encode/decode a JSON string when the gc kicks in, it will take a lot longer because of all the stuff that isn't JSON related.

I don't think it can be suggested that timeit should grow a flag for "put garbage into memory, and then run this microbenchmark with gc enabled.".

If you really want to know how fast something is in your application, you sort of have to do the timing in your application, at scale and at load.

John =:->

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6dLwMACgkQJdeBCYSNAAOzzACfXpP16589Mu7W8ls9KddacF+g ozwAnRz5ciPg950qcV2uzyTKl1R21+6t =hGgf -----END PGP SIGNATURE-----



More information about the Python-Dev mailing list