Skip to content

Commit 047fd68

Browse files
MarekPietakapi-no
authored andcommitted
scripts: nrf_profiler: Introduce README.rst
Change moves nRF Profiler Python scripts documentation to a separate `README.rst` file. Change also updates existing documentation related to nRF Profiler to take into account the newly introduced page. Jira: NCSDK-32015 Signed-off-by: Marek Pieta <[email protected]> Signed-off-by: Divya Pillai <[email protected]> Signed-off-by: Pekka Niskanen <[email protected]>
1 parent b246757 commit 047fd68

File tree

9 files changed

+185
-175
lines changed

9 files changed

+185
-175
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@
720720
/scripts/docker/*.rst @nrfconnect/ncs-doc-leads
721721
/scripts/hid_configurator/*.rst @nrfconnect/ncs-si-bluebagel-doc
722722
/scripts/memfault/*.rst @nrfconnect/ncs-cia-doc
723+
/scripts/nrf_profiler/*.rst @nrfconnect/ncs-si-bluebagel-doc
723724
/scripts/nrf_provision/fast_pair/*.rst @nrfconnect/ncs-si-bluebagel-doc
724725
/scripts/partition_manager/*.rst @nrfconnect/ncs-aurora-doc
725726
/scripts/generate_psa_key_attributes/*.rst @nrfconnect/ncs-aegir-doc

doc/nrf/libraries/others/app_event_manager_profiler_tracer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ To profile an Application Event Manager event, you must complete the following s
9595
* By default, all Application Event Manager events that are defined with an :c:struct:`event_info` argument are profiled.
9696
* :c:struct:`sample_event_info` is defined within the :c:macro:`APP_EVENT_INFO_DEFINE` macro.
9797

98-
#. Use the Profiler Python scripts to profile the application.
99-
See :ref:`nrf_profiler_backends` in the Profiler documentation for details.
98+
#. Use the nRF Profiler host tools to profile the application.
99+
See :ref:`nrf_profiler_script` documentation page for details.
100100

101101
Implementation details
102102
**********************

doc/nrf/libraries/others/nrf_profiler.rst

Lines changed: 13 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ nRF Profiler
77
:local:
88
:depth: 2
99

10-
The nRF Profiler provides an interface for logging and visualizing data for performance measurements, while the system is running.
10+
The nRF Profiler library allows for performance measurements of an embedded device.
11+
The library provides an interface for lightweight logging of nRF Profiler events together with associated timestamp and data.
12+
This allows you to deliver information about the system state with minimal negative impact on performance.
1113
You can use the module to profile :ref:`app_event_manager` events or custom events.
12-
The output is provided using RTT and can be visualized in a custom Python backend.
14+
15+
The nRF Profiler supports one backend that provides output to the host computer using RTT.
16+
You can use a dedicated set of host tools available in the |NCS| to visualize and analyze the collected nRF Profiler events.
17+
See the :ref:`nrf_profiler_script` page for details.
1318

1419
See the :ref:`nrf_profiler_sample` sample for an example of how to use the nRF Profiler.
1520

@@ -18,7 +23,7 @@ See the :ref:`nrf_profiler_sample` sample for an example of how to use the nRF P
1823
Configuration
1924
*************
2025

21-
Since Application Event Manager events are converted to nRF Profiler events, the nRF Profiler can be configured to profile custom events or Application Event Manager events, or both.
26+
Since Application Event Manager events are converted to nRF Profiler events by the :ref:`app_event_manager_profiler_tracer`, you can configure the nRF Profiler to profile custom events or Application Event Manager events, or both.
2227

2328
Configuring for use with custom events
2429
======================================
@@ -89,119 +94,15 @@ To profile custom events, complete the following steps:
8994
nrf_profiler_log_send(&buf, data_event_id);
9095
}
9196
92-
.. note::
93-
94-
The ``data_event_id`` and the data that is profiled with the event must be consistent with the registered event type.
95-
The data for every data field must be provided in the correct order.
97+
.. note::
98+
The ``data_event_id`` and the data that is profiled with the event must be consistent with the registered event type.
99+
The data for every data field must be provided in the correct order.
96100

97101
Configuration for use with Application Event Manager
98102
====================================================
99103

100-
If you are using the Application Event Manager, in order to use the nRF Profiler follow the steps in
101-
:ref:`app_event_manager_profiler_tracer_em_implementation` and :ref:`app_event_manager_profiler_tracer_config` on the :ref:`app_event_manager_profiler_tracer` documentation page.
102-
103-
.. _nrf_profiler_backends:
104-
105-
Enabling supported backend
106-
**************************
107-
108-
The nRF Profiler supports a custom backend that is based around Python scripts to visualize the output data.
109-
The backend communicates with the host using RTT.
110-
111-
To save profiling data, the scripts use CSV files for event occurrences and JSON files for event descriptions.
112-
113-
Available scripts
114-
=================
115-
116-
The scripts can be found under :file:`scripts/nrf_profiler/` in the |NCS| folder structure.
117-
The following script files are available:
118-
119-
* :file:`data_collector.py` - This script connects to the device using RTT, receives profiling data, and saves it to files.
120-
When running the script from the command line, provide the time for collecting data (in seconds) and the dataset name.
121-
For example:
122-
123-
.. parsed-literal::
124-
:class: highlight
125-
126-
python3 data_collector.py 5 test1
127-
128-
In this command, ``5`` is the time value for collecting data and ``test1`` is the dataset name.
129-
* :file:`plot_from_files.py` - This script plots events from the dataset that is provided as the command-line argument.
130-
For example:
131-
132-
.. parsed-literal::
133-
:class: highlight
134-
135-
python3 plot_from_files.py test1
136-
137-
In this command, ``test1`` is the dataset name.
138-
* :file:`real_time_plot.py` - This script connects to the device using RTT, plots data in real-time, and saves the data.
139-
When running the script from the command line, provide the dataset name.
140-
For example:
141-
142-
.. parsed-literal::
143-
:class: highlight
144-
145-
python3 real_time_plot.py test1
146-
147-
* :file:`merge_data.py` - This script combines data from ``test_p`` and ``test_c`` datasets into one dataset ``test_merged``.
148-
It also provides clock drift compensation based on the synchronization events: ``sync_event_p`` and ``sync_event_c``.
149-
This enables you to observe times between events for the two connected devices.
150-
As command-line arguments, provide names of events used for synchronization for a Peripheral (``sync_event_p``) and a Central (``sync_event_c``), as well as names of datasets for the Peripheral (``test_p``), the Central (``test_c``), and the merge result (``test_merged``).
151-
For example:
152-
153-
.. parsed-literal::
154-
:class: highlight
155-
156-
python3 merge_data.py test_p sync_event_p test_c sync_event_c test_merged
157-
158-
159-
Running the backend
160-
===================
161-
162-
To enable and run the custom backend, complete the following steps:
163-
164-
1. Connect device to the computer.
165-
2. Complete the configuration steps for use with either custom events or Application Event Manager, as described in the :ref:`nrf_profiler_configuration` section.
166-
#. From the list of `Available scripts`_, choose the Python script that you want to use for event visualization, analysis, and calculating statistics.
167-
#. Run the script from the command line using its related command.
168-
169-
.. _nrf_profiler_backends_custom_visualization:
170-
171-
Backend visualization
172-
=====================
173-
174-
When you run either the :file:`plot_from_files.py` or the :file:`real_time_plot.py` script, the profiled events are visualized in a GUI window.
175-
176-
The visual output can look like the following diagram:
177-
178-
.. nrf_profiler_GUI_start
179-
180-
.. figure:: ../../images/app_event_manager_profiling_sample.png
181-
:scale: 50 %
182-
:alt: Example of nRF Profiler backend script visualization
183-
184-
Example of nRF Profiler backend script visualization
185-
186-
.. nrf_profiler_GUI_end
187-
188-
In this diagram:
189-
190-
* Red dots indicate the submissions for the related events.
191-
* Blue vertical rectangles indicate the processing of the events, with their width corresponding to the processing time length.
192-
* The :guilabel:`Start/Stop` button can be used to pause or resume the real-time plot translation.
193-
194-
The GUI also supports the following actions:
195-
196-
* Scrolling on the diagram using the mouse wheel zooms it in or out.
197-
198-
* When plotting is paused, scrolling zooms to the cursor location.
199-
* When plotting in running, scrolling zooms to the right edge of the plot.
200-
201-
* Middle mouse button can be used to mark an event submission or processing for tracking, and to display the event data.
202-
* When plotting is paused, you can click and drag with the left mouse button to pan the plot.
203-
* You can click the left or right mouse button to place a vertical line at the cursor location.
204-
When two lines are present, the application measures the time between them and displays it.
104+
To use the nRF Profiler for Application Event Manager events, refer to the :ref:`app_event_manager_profiler_tracer` documentation.
105+
The Application Event Manager profiler tracer automatically initializes the nRF Profiler and then acts as a linking layer between :ref:`app_event_manager` and the nRF Profiler.
205106

206107
Shell integration
207108
*****************

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,9 @@ nRF RPC libraries
593593
Other libraries
594594
---------------
595595

596-
|no_changes_yet_note|
596+
* :ref:`nrf_profiler` library:
597+
598+
* Updated the documentation by separating out the :ref:`nrf_profiler_script` documentation.
597599

598600
Shell libraries
599601
---------------
@@ -608,7 +610,10 @@ See the changelog for each library in the :doc:`nrfxlib documentation <nrfxlib:R
608610
Scripts
609611
=======
610612

611-
* Added the :ref:`esb_sniffer_scripts` scripts for the :ref:`esb_monitor` sample.
613+
* Added:
614+
615+
* The :ref:`esb_sniffer_scripts` scripts for the :ref:`esb_monitor` sample.
616+
* The documentation page for :ref:`nrf_profiler_script`.
612617

613618
Integrations
614619
============

doc/nrf/scripts.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Here you can find documentation for these scripts.
1717
../../scripts/generate_psa_key_attributes/*
1818
../../scripts/hid_configurator/*
1919
../../scripts/memfault/*
20+
../../scripts/nrf_profiler/*
2021
../../scripts/nrf_provision/*/*
2122
../../scripts/partition_manager/*
2223
../../scripts/shell/*/*

samples/app_event_manager_profiler_tracer/README.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,27 @@ After programming the sample to your development kit, test it by performing the
8282
8383
The script opens a GUI window that displays events as points on timelines, similar to the following:
8484

85-
.. include:: ../../doc/nrf/libraries/others/nrf_profiler.rst
86-
:start-after: nrf_profiler_GUI_start
87-
:end-before: nrf_profiler_GUI_end
85+
.. figure:: ../../doc/nrf/images/app_event_manager_profiling_sample.png
86+
:scale: 50 %
87+
:alt: nRF Profiler host tools GUI window
88+
89+
nRF Profiler host tools GUI window
8890

89-
#. Use scroll wheel to zoom into interesting parts on a GUI.
90-
See the :ref:`nrf_profiler_backends_custom_visualization` in the Profiler documentation for more information about how to work with the diagram.
91+
#. Use the scroll wheel to zoom into interesting parts on a plot.
92+
See the :ref:`nrf_profiler_script_visualization_GUI` section in the nRF Profiler host tools documentation for more information about how to navigate in the GUI window.
9193
#. Click the middle mouse button to highlight an event submission or processing for tracking, and to display the event data as on a figure:
9294

9395
.. figure:: ../../doc/nrf/images/app_event_manager_profiling_sample_zoom.png
9496
:scale: 50 %
95-
:alt: Diagram of GUI output zoomed in
97+
:alt: nRF Profiler host tools GUI window zoomed in
9698

97-
Sample diagram of zoomed-in GUI output
99+
nRF Profiler host tools GUI window zoomed in
98100

99101
On this image, the zoom focuses on actions triggered by the fifth one-second event.
100102
The five-second event triggers 50 burst events.
101103
One event submission and corresponding processing time is highlighted in green.
102104
#. Check the results for the generated :file:`test_name.csv` and :file:`test_name.json` files.
103-
#. See how events are logged with data transmitted by the event.
105+
See how events are logged with data transmitted by the event.
104106
#. Calculate the nRF Profiler event propagation statistics (statistics for time intervals between nRF Profiler events) from the previously collected dataset using the following command:
105107

106108
.. code-block:: console

samples/nrf_profiler/README.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ After programming the sample to your development kit, you can test it by perform
5454
python3 real_time_plot.py *test_name*
5555
5656
This command generates a :file:`test_name.csv` file and a :file:`test_name.json` file.
57-
The script opens a GUI window that displays events as dots on timelines, similar to the following diagram.
57+
The script opens a GUI window that displays events as dots on timelines, similar to the following plot.
5858

59-
.. include:: ../../doc/nrf/libraries/others/nrf_profiler.rst
60-
:start-after: nrf_profiler_GUI_start
61-
:end-before: nrf_profiler_GUI_end
59+
.. figure:: ../../doc/nrf/images/app_event_manager_profiling_sample.png
60+
:scale: 50 %
61+
:alt: Example of nRF Profiler host tools GUI window
6262

63-
See the :ref:`nrf_profiler_backends_custom_visualization` section in the nRF Profiler documentation for more information about the GUI.
63+
Example of nRF Profiler host tools GUI window
64+
65+
See the :ref:`nrf_profiler_script_visualization_GUI` section in the nRF Profiler host tools documentation for more information about the GUI.
6466

6567
#. |connect_terminal|
6668
After you connect, the sample will display messages in the terminal.

0 commit comments

Comments
 (0)