User Tools

Site Tools


competitive_programming:development_utilities

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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:
  
 </code> </code>
 +
 +<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__ == "__main__":
 +    foo(10000)
 +    bar(100000)
 +    baz(1000000)
 +</file>
 +
 +<code bash>
 +$ python -m cProfile -s cumtime profile.py
 +         8 function calls in 0.059 seconds
 +
 +   Ordered by: cumulative time
 +
 +   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 +        1    0.000    0.000    0.059    0.059 profile.py:1(<module>)
 +        1    0.035    0.035    0.054    0.054 profile.py:11(baz)
 +        3    0.021    0.007    0.021    0.007 {range}
 +        1    0.003    0.003    0.005    0.005 profile.py:6(bar)
 +        1    0.000    0.000    0.000    0.000 profile.py:1(foo)
 +        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
 +</code>
 +
 +==== Debugging Tools ====
 +=== Memory Leak Detection ===
 +== Valgrind ==
  
  
competitive_programming/development_utilities.1536781104.txt.gz ยท Last modified: 2018/09/12 14:38 by jguerin