File tree Expand file tree Collapse file tree 8 files changed +728
-0
lines changed Expand file tree Collapse file tree 8 files changed +728
-0
lines changed Original file line number Diff line number Diff line change 1+ # Copyright (c) 2023 KNS Group LLC (YADRO)
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
4+
5+ cmake_minimum_required (VERSION 3.20.0)
6+
7+ find_package (Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} )
8+ project (perf)
9+
10+ target_sources (app PRIVATE src/main.c)
Original file line number Diff line number Diff line change 1+ .. zephyr :code-sample :: profiling-perf
2+ :name: Perf tool
3+
4+ Send perf samples to the host with console support
5+
6+ This application can be used to demonstrate :ref: `profiling-perf ` work.
7+
8+ Requirements
9+ ************
10+
11+ Perf tool so far implemente only for riscv and x86_64 architectures.
12+
13+ Usage example
14+ *************
15+
16+ Build an image with:
17+
18+ .. zephyr-app-commands ::
19+ :zephyr-app: samples/subsys/profiling/perf
20+ :board: qemu_riscv64
21+ :goals: build
22+ :compact:
23+
24+ After the sample starts, enter shell command:
25+
26+ .. code-block :: console
27+
28+ uart:~$ perf record <period> <frequency>
29+
30+ Wait for the completion message ``perf done! `` or ``perf buf override! ``
31+ (if perf buffer size is smaller than required).
32+
33+ Print made by perf samles in terminal by shell-command:
34+
35+ .. code-block :: console
36+
37+ uart:~$ perf printbuf
38+
39+ Output exaple:
40+
41+ .. code-block :: console
42+
43+ Perf buf length 2046
44+ 0000000000000004
45+ 00000000001056b2
46+ 0000000000108192
47+ 000000000010052f
48+ 0000000000000000
49+ ....
50+ 000000000010052f
51+ 0000000000000000
52+
53+ Copy gotten output in some file, for example *perf_buf *.
54+
55+ Make graph.svg with :zephyr_file: `scripts/perf/stackcollapse.py ` and
56+ `FlameGraph `_:
57+
58+ .. _FlameGraph : https://github.com/brendangregg/FlameGraph/
59+
60+ .. code-block :: shell
61+
62+ python scripts/perf/stackcollapse.py perf_buf build/zephyr/zephyr.elf | < flamegraph_dir_path> /flamegraph.pl > graph.svg
63+
64+ Graph example
65+ =============
66+
67+ .. image :: images/graph_example.svg
68+ :align: center
69+ :alt: graph example
You can’t perform that action at this time.
0 commit comments