Benchmarking, profiling and performanceΒΆ
When benchmarking code it is important to reduce other load on the system
(music player, web browser for example). One can use the python timeit
module or a command line utility like hyperfine:
python -m timeit -s 'from khard.khard import main' 'main(["list"])'
hyperfine 'python -m khard list'
For profiling the cProfile
python module works well. With the help of
gprof2dot one can generate quite useful graphs:
python -m cProfile -o output.file -m khard list
gprof2dot -f pstats --show-samples output.file | dot -T png > graph.png
xdg-open graph.png