Skip to content

Commit 132a44b

Browse files
MarekPietakapi-no
authored andcommitted
scripts: nrf_profiler: Document stats calculating script
Change introduces documenation for the `calc_stats.py` script. Jira: NCSDK-32015 Signed-off-by: Marek Pieta <[email protected]> Signed-off-by: Pekka Niskanen <[email protected]> Signed-off-by: Divya Pillai <[email protected]>
1 parent b8e3ae8 commit 132a44b

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ Scripts
630630

631631
* The :ref:`esb_sniffer_scripts` scripts for the :ref:`esb_monitor` sample.
632632
* The documentation page for :ref:`nrf_profiler_script`.
633+
The page also describes the script for calculating statistics (:file:`calc_stats.py`).
633634

634635
Integrations
635636
============

samples/app_event_manager_profiler_tracer/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ After programming the sample to your development kit, test it by performing the
111111
112112
The :file:`stats_nordic_presets/app_event_manager_profiler_tracer.json` file specifies the nRF Profiler events used for the calculations.
113113
The file refers to the events used by the sample.
114+
See the :ref:`nrf_profiler_script_calculating_statistics` section in the nRF Profiler host tools documentation for more information.
114115

115116
Dependencies
116117
************

samples/nrf_profiler/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ After programming the sample to your development kit, you can test it by perform
7474
7575
The :file:`stats_nordic_presets/nrf_profiler.json` file specifies the nRF Profiler events used for the calculations.
7676
The file refers to the events used by the sample.
77+
See the :ref:`nrf_profiler_script_calculating_statistics` section in the nRF Profiler host tools documentation for more information.
7778

7879
Dependencies
7980
************

scripts/nrf_profiler/README.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,82 @@ You can use it for visualization or calculating statistics.
137137
An application must provide its own implementation.
138138
See the :ref:`nrf_desktop_nrf_profiler_sync` for an example implementation used by the :ref:`nrf_desktop` application.
139139

140+
.. _nrf_profiler_script_calculating_statistics:
141+
142+
Calculating statistics
143+
======================
144+
145+
The :file:`calc_stats.py` script is used to calculate and visualize the nRF Profiler event propagation statistics (statistics for time intervals between nRF Profiler events) for a given dataset.
146+
A JSON file containing test presets specifies the events to be analyzed.
147+
The script calculates and displays the following statistics for each test preset:
148+
149+
* basic statistics (min, max, mean, median, standard deviation)
150+
* histogram plot
151+
* plot of subsequent time intervals between events
152+
153+
For some of the statistics, the script also filters out time intervals that deviate from the other records.
154+
These statistics are denoted by a ``no outliers`` suffix in the plot title and output file name.
155+
156+
Apart from displaying the statistics, the scipts also stores them as local files under the :file:`data_stats/` directory.
157+
The results are organized in subdirectories based on the dataset name, time range, and test preset name.
158+
159+
When running the script from the command line, provide the dataset name (``test1``) and path to the JSON file containing test presets (:file:`stats_nordic_presets/app_event_manager_profiler_tracer.json`).
160+
161+
.. code-block:: console
162+
163+
python3 calc_stats.py test1 stats_nordic_presets/app_event_manager_profiler_tracer.json
164+
165+
.. tip::
166+
Before calculating statistics using the example command, you need to collect profiling data from a device running the :ref:`app_event_manager_profiling_tracer_sample` sample and store the data as the ``test1`` dataset.
167+
Make sure to use the mentioned sample, because the test preset refers to sample-specific nRF Profiler event names.
168+
169+
If you want to calculate statistics for your own application, you need to create a new test preset file that refers to the nRF Profiler events used by your application.
170+
You can use the script to calculate statistics for custom nRF Profiler events or Application Event Manager events, or both.
171+
172+
Test preset JSON file format
173+
----------------------------
174+
175+
The test preset JSON file contains an array of test presets.
176+
Every test preset is identified by a unique name.
177+
The script calculates the time intervals between start and end events specified by each test preset.
178+
The script uses the time intervals as input data for calculating statistics.
179+
180+
An example of an array containing a single test preset looks as follows:
181+
182+
.. code-block:: json
183+
184+
[
185+
{
186+
"name": "Test Name",
187+
"start_event": {
188+
"name": "event_name_1",
189+
"state": "submit"
190+
},
191+
"end_event": {
192+
"name": "event_name_2",
193+
"state": "processing_end"
194+
}
195+
}
196+
]
197+
198+
Fields:
199+
200+
* ``name`` - Name of the test preset (used for output files and plot titles)
201+
* ``start_event`` - Configuration for the start event
202+
203+
* ``name`` - Name of the event
204+
* ``state`` - Event state (optional, defaults to "submit")
205+
206+
Possible values:
207+
208+
* ``submit`` - Event submission
209+
* ``processing_start`` - Event processing start (only for Application Event Manager events)
210+
* ``processing_end`` - Event processing end (only for Application Event Manager events)
211+
212+
* ``end_event`` - Configuration for the end event (same format as ``start_event``)
213+
214+
For examples of the test preset JSON file, see the :file:`stats_nordic_presets/` directory.
215+
140216
Dependencies
141217
************
142218

0 commit comments

Comments
 (0)