Spacing and timing for comparing algorithms and data-structures

Chris Rebert clp2 at rebertia.com
Fri Mar 2 06:44:05 CET 2012


On Thu, Mar 1, 2012 at 8:55 PM, Alec Taylor <alec.taylor6 at gmail.com> wrote:
> What would you recommend I use to compare data-structures and
> algorithms on space and time? (runtime)

For the latter metric, one of the profiling modules:
http://docs.python.org/library/debug.html
I'd start with timeit and go from there:
http://docs.python.org/library/timeit.html

For the former metric, you can write your own memory use measurement
utility function on top of:
http://docs.python.org/library/sys.html#sys.getsizeof
Or there is doubtless some Unix tool(s) you could use to get a more
crude measure of the total memory used by the Python interpreter
process.

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list