This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
competitive_programming:development_utilities [2018/09/12 14:38] jguerin Added some structure, cProfile example. |
competitive_programming:development_utilities [2018/09/12 14:49] (current) jguerin Added some additional headers for Valgrind. |
||
|---|---|---|---|
| Line 18: | Line 18: | ||
| </ | </ | ||
| + | |||
| + | <file python profile.py> | ||
| + | def foo(iters): | ||
| + | x = 0 | ||
| + | for i in range(iters): | ||
| + | x += 1 | ||
| + | |||
| + | def bar(iters): | ||
| + | x = 0 | ||
| + | for i in range(iters): | ||
| + | x += 1 | ||
| + | |||
| + | def baz(iters): | ||
| + | x = 0 | ||
| + | for i in range(iters): | ||
| + | x += 1 | ||
| + | |||
| + | |||
| + | if __name__ == " | ||
| + | foo(10000) | ||
| + | bar(100000) | ||
| + | baz(1000000) | ||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | $ python -m cProfile -s cumtime profile.py | ||
| + | 8 function calls in 0.059 seconds | ||
| + | |||
| + | | ||
| + | |||
| + | | ||
| + | 1 0.000 0.000 0.059 0.059 profile.py: | ||
| + | 1 0.035 0.035 0.054 0.054 profile.py: | ||
| + | 3 0.021 0.007 0.021 0.007 {range} | ||
| + | 1 0.003 0.003 0.005 0.005 profile.py: | ||
| + | 1 0.000 0.000 0.000 0.000 profile.py: | ||
| + | 1 0.000 0.000 0.000 0.000 {method ' | ||
| + | </ | ||
| + | |||
| + | ==== Debugging Tools ==== | ||
| + | === Memory Leak Detection === | ||
| + | == Valgrind == | ||