code:profiling
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| code:profiling [2009/11/30 01:25] – external edit 127.0.0.1 | code:profiling [2020/03/29 12:13] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| ===== Dynamic Memory Allocation ===== | ===== Dynamic Memory Allocation ===== | ||
| - | The biggest | + | Typical |
| - leaks and | - leaks and | ||
| - corruption. | - corruption. | ||
| - | While the later is rather tricky to analyse, for memleaks there is | + | While the latter |
| '' | '' | ||
| < | < | ||
| Line 17: | Line 17: | ||
| ===== Performance ===== | ===== Performance ===== | ||
| - | When programming, | + | When programming, |
| - | identifying | + | CPU-intense algorithms. Reducing code complexity often doesn' |
| - | doesn' | + | E.g. IO-intense operations often lead to delays at run-time which isn't covered |
| - | run-time which isn't covered by the O-notation, at all. This means that aside | + | by O-notation, at all. This means that aside of complexity analysis, there |
| - | of complexity analysis, there always should be run-time code execution time | + | always should be run-time code execution time measurement. |
| - | measurement. | + | |
| + | ==== GProf ==== | ||
| + | |||
| + | '' | ||
| + | program collects profiling data for later analysis using '' | ||
| < | < | ||
| $ gcc -pg -g test.c | $ gcc -pg -g test.c | ||
| $ ./a.out | $ ./a.out | ||
| $ gprof a.out gmon.out | $ gprof a.out gmon.out | ||
| + | </ | ||
| + | |||
| + | ==== Perf ==== | ||
| + | |||
| + | On recent kernels, '' | ||
| + | whole system like with obsoleted OProfile but may be limited to a single | ||
| + | program, also. Before executing the workload to profile (or while it is | ||
| + | running), call: | ||
| + | < | ||
| + | # perf record | ||
| + | </ | ||
| + | When done, finish recording using '' | ||
| + | < | ||
| + | # perf report | ||
| + | </ | ||
| + | |||
| + | ==== Python ==== | ||
| + | |||
| + | Profiling Python is pretty simple, using cPython module: | ||
| + | < | ||
| + | $ python -m cPython myscript.py | ||
| </ | </ | ||
| Line 45: | Line 71: | ||
| of //test.c//. | of //test.c//. | ||
| + | If linking happens in a separate step, some additional flags have to be passed to linker: | ||
| + | < | ||
| + | CFLAGS | ||
| + | LDFLAGS += -lgcov --coverage | ||
| + | </ | ||
code/profiling.1259544302.txt.gz · Last modified: by 127.0.0.1
