code:profiling
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
code:profiling [2017/12/22 14:25] – phil | 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 | ||
</ | </ | ||
Line 52: | 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.txt · Last modified: 2020/03/29 12:13 by 127.0.0.1