The document discusses Python profiling tools for optimizing code performance. It introduces common profiling tools like cProfile and memory_profiler and demonstrates using them to analyze a minification script. Additional tools like meliae, heapy, and valgrind are listed. Profiling Django applications is also covered, with mentions of debug toolbar, django-profiler, and New Relic.
7. “We should forget about small efficiencies, say
about 97% of the time: premature optimization
is the root of all evil” - Donald Knuth
Friday, October 4, 13
8. from timeit import timeit
if __name__ == "__main__":
setup = "from htmlmin.minify import html_minify;"
setup += "from data import raw_html"
t = timeit(
stmt="html_minify(raw_html)",
setup=setup,
number=100)
print(t)
benchmark.py
Friday, October 4, 13