66 lines
1.9 KiB
Markdown
66 lines
1.9 KiB
Markdown
---
|
||
title: Профилирование кода
|
||
category: Программирование
|
||
tags: программирование, отладка, производительность, профилирование, gprof
|
||
summary:
|
||
...
|
||
|
||
## Общее описание
|
||
|
||
Чтобы профилировать приложения, компилируемые [GCC](http://gcc.gnu.org),
|
||
необходимо добавлять флаг `-fno-omit-frame-pointer` и желательно `-g`.
|
||
|
||
## quickstack
|
||
|
||
Утилита для отслеживания стеков вызовов функций [quicktrack](https://github.com/yoshinorim/quickstack).
|
||
Пример использования:
|
||
|
||
```sh
|
||
quickstack -f -p $(pidof application)
|
||
```
|
||
|
||
## perf
|
||
|
||
Утилита профилирования для ядра Linux (находится в дереве его исходных текстов
|
||
в каталоге `tools/perf`).
|
||
|
||
```sh
|
||
perf record --call-graph dwarf -- yourapp
|
||
perf report -g graph --no-children
|
||
```
|
||
|
||
Полезные ссылки:
|
||
|
||
* [Официальная страница](https://perf.wiki.kernel.org/index.php/Main_Page)
|
||
* [Примеры](https://stackoverflow.com/questions/1777556/alternatives-to-gprof/10958510#10958510)
|
||
* [Примеры](http://www.brendangregg.com/perf.html)
|
||
|
||
## oprofile
|
||
|
||
```sh
|
||
opcontrol --setup --vmlinux=/boot/vmlinux-`uname -r`
|
||
```
|
||
|
||
## Systemtap
|
||
|
||
[Установка и простые примеры использования SystemTap](https://eax.me/systemtap/)
|
||
|
||
|
||
## Valgrind
|
||
|
||
|
||
## gperftools
|
||
|
||
|
||
## Разное
|
||
|
||
* [Профилирование кода на C/C++ в Linux и FreeBSD](https://eax.me/c-cpp-profiling/)
|
||
* [Примеры](http://gernotklingler.com/blog/gprof-valgrind-gperftools-evaluation-tools-application-level-cpu-profiling-linux/)
|
||
|
||
|
||
## Графическое отображение
|
||
|
||
* [Flame Graphs](http://www.brendangregg.com/flamegraphs.html)
|
||
* [gprof2dot](https://github.com/jrfonseca/gprof2dot)
|
||
|