All languages

Python for DevOps

You're viewing a free preview. Sign in free to read every script.

Why this exists "The report takes ten minutes" and "the worker's memory keeps growing until it is killed" are ordinary problems in long running automation. The temptation is to guess (that loop looks slow) and rewrite…

Python for DevOps: Profiling a Slow Script with timeit and cProfile, and Finding a Memory Leak with tracemalloc

Measure before you optimise: time small pieces with timeit, find the real hot spot with cProfile (and be surprised by where the time goes), prove a fix with numbers, and locate a leaking cache with tracemalloc snapshots.

Sign in free to read this script, along with the rest of the library.

Sign in free