Skip to content

Commit 42a5187

Browse files
MarekPietakapi-no
authored andcommitted
scripts: nrf_profiler: Add interval plot to StatsNordic
Change introduces interval plot to the StatsNordic class. Jira: NCSDK-31712 Signed-off-by: Marek Pieta <[email protected]>
1 parent 77211bd commit 42a5187

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

scripts/nrf_profiler/stats_nordic.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ def _times_between_to_histogram(preset_desc, output_dir, times_between_ms,
130130
plt.yscale("log")
131131
plt.savefig(os.path.join(output_dir, "{}_log.png".format(out_filename)))
132132

133+
@staticmethod
134+
def _times_between_to_interval_plot(preset_desc, output_dir, start_times, times_between_ms,
135+
out_filename="interval_plot"):
136+
plt.figure()
137+
138+
plt.xlabel("Start event timestamp [s]")
139+
plt.ylabel("Time between events [ms]")
140+
plt.title(preset_desc)
141+
plt.grid(True)
142+
143+
plt.plot(start_times, times_between_ms, ".")
144+
plt.savefig(os.path.join(output_dir, "{}.png".format(out_filename)))
145+
133146
@staticmethod
134147
def _test_preset_parse_event(event_dict):
135148
if event_dict is None:
@@ -183,13 +196,20 @@ def _test_preset_execute(self, test_preset, start_time, end_time):
183196
# Filter out outliers
184197
mask = StatsNordic._get_outlier_filter_mask(times_between_ms)
185198
times_between_ms_no_outliers = times_between_ms[mask]
199+
ts_start_no_outliers = ts_start[mask]
186200

187201
# Store results in the output directory
188202
StatsNordic._times_between_to_stats_txt(preset_desc, output_dir, times_between_ms,
189203
logger=self.logger)
190204
StatsNordic._times_between_to_histogram(preset_desc + " no outliers", output_dir,
191205
times_between_ms_no_outliers,
192206
out_filename="histogram_no_outliers")
207+
StatsNordic._times_between_to_interval_plot(preset_desc, output_dir, ts_start,
208+
times_between_ms)
209+
StatsNordic._times_between_to_interval_plot(preset_desc + " no outliers", output_dir,
210+
ts_start_no_outliers,
211+
times_between_ms_no_outliers,
212+
out_filename="interval_plot_no_outliers")
193213

194214
# Display all of the figures to the user
195215
plt.show()

0 commit comments

Comments
 (0)