Ben Chuanlong Du's Blog

It is never too late to learn.

Profile Rust Applications Using Flamegraph

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Tips and Traps

  1. not-perf is the best CPU profiling tool for Rust application.

  2. Valgrind is another good alternative to flamegraph if performance is not a big issue. However, profiling an application …

Profile Performance of Python Applications

Tips

  1. cProfile (implemented in C) is preferred over profile (implemented in Python).

  2. The profiler modules (cProfile and profile) and tools based on them (e.g., %prun and %%prun for notebook) are designed to provide an execution profile for a given program, not for benchmarking purposes (for that, there is time

Python Profiler for JupyterLab Notebooks

%time

Measue the execuation time of the code ONCE.

%timeit

Measure the execuation time of the code (accurately) by running it MULTIPLE TIMES and taking the average.

%prun | %%prun

-D: output the profiling results into a file so that you can other tools (e.g., snakeviz) to visualize it.

Noticd that %prun and %%prun are based on cProfile