Skip to content

Commit

Permalink
tests: latency_measure: Change reporting strings
Browse files Browse the repository at this point in the history
Changes the summary lines used in the latency_measure benchmark
so that they follow a consistent pattern.

    OBJECT  action.<brief details about action>

This makes it easier to locate results belonging to a particular
object group. It also has the benefit to keep results colocated
should the output be sorted by an external tool.

Signed-off-by: Peter Mitsis <[email protected]>
  • Loading branch information
peter-mitsis authored and aescolar committed Jan 5, 2024
1 parent 6291a57 commit 911182c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions tests/benchmarks/latency_measure/src/heap_malloc_free.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ void heap_malloc_free(void)
notes = "Memory heap too small--increase it.";
}

PRINT_STATS_AVG("Average time for heap malloc", sum_malloc, count,
PRINT_STATS_AVG("HEAP malloc.immediate", sum_malloc, count,
failed, notes);
PRINT_STATS_AVG("Average time for heap free", sum_free, count,
PRINT_STATS_AVG("HEAP free.immediate", sum_free, count,
failed, notes);

timing_stop();
Expand Down
6 changes: 3 additions & 3 deletions tests/benchmarks/latency_measure/src/int_to_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int int_to_thread(uint32_t num_iterations)

sum -= timestamp_overhead_adjustment(0, 0);

PRINT_STATS_AVG("Switch from ISR back to interrupted thread",
PRINT_STATS_AVG("ISR resume.interrupted.thread.kernel",
(uint32_t)sum, num_iterations, false, "");

/* ************** */
Expand All @@ -183,7 +183,7 @@ int int_to_thread(uint32_t num_iterations)

sum -= timestamp_overhead_adjustment(0, 0);

PRINT_STATS_AVG("Switch from ISR to another thread (kernel)",
PRINT_STATS_AVG("ISR resume.different.thread.kernel",
(uint32_t)sum, num_iterations, false, "");

/* ************** */
Expand All @@ -193,7 +193,7 @@ int int_to_thread(uint32_t num_iterations)

sum -= timestamp_overhead_adjustment(0, K_USER);

PRINT_STATS_AVG("Switch from ISR to another thread (user)",
PRINT_STATS_AVG("ISR resume.different.thread.user",
(uint32_t)sum, num_iterations, false, "");
#endif

Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/latency_measure/src/mutex_lock_unlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ int mutex_lock_unlock(uint32_t num_iterations, uint32_t options)
k_sem_give(&pause_sem);

snprintf(description, sizeof(description),
"Lock a mutex from %s thread",
"MUTEX lock.immediate.recursive.%s",
(options & K_USER) == K_USER ? "user" : "kernel");
PRINT_STATS_AVG(description, (uint32_t)cycles, num_iterations,
false, "");

cycles = timestamp.cycles;

snprintf(description, sizeof(description),
"Unlock a mutex from %s thread",
"MUTEX unlock.immediate.recursive.%s",
(options & K_USER) == K_USER ? "user" : "kernel");
PRINT_STATS_AVG(description, (uint32_t)cycles, num_iterations,
false, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void sema_context_switch(uint32_t num_iterations,
cycles -= timestamp_overhead_adjustment(start_options, alt_options);

snprintf(description, sizeof(description),
"Take a semaphore (context switch %c -> %c)",
"SEMAPHORE take.blocking.(%c -> %c)",
((start_options & K_USER) == K_USER) ? 'U' : 'K',
((alt_options & K_USER) == K_USER) ? 'U' : 'K');
PRINT_STATS_AVG(description, (uint32_t)cycles,
Expand All @@ -155,7 +155,7 @@ void sema_context_switch(uint32_t num_iterations,
cycles -= timestamp_overhead_adjustment(start_options, alt_options);

snprintf(description, sizeof(description),
"Give a semaphore (context switch %c -> %c)",
"SEMAPHORE give.wake+ctx.(%c -> %c)",
((alt_options & K_USER) == K_USER) ? 'U' : 'K',
((start_options & K_USER) == K_USER) ? 'U' : 'K');
PRINT_STATS_AVG(description, (uint32_t)cycles,
Expand Down Expand Up @@ -255,7 +255,7 @@ int sema_test_signal(uint32_t num_iterations, uint32_t options)
cycles = timestamp.cycles;

snprintf(description, sizeof(description),
"Give a semaphore (no waiters) from %s thread",
"SEMAPHORE give.immediate.%s",
(options & K_USER) == K_USER ? "user" : "kernel");

PRINT_STATS_AVG(description, (uint32_t)cycles,
Expand All @@ -274,7 +274,7 @@ int sema_test_signal(uint32_t num_iterations, uint32_t options)
cycles = timestamp.cycles;

snprintf(description, sizeof(description),
"Take a semaphore (no blocking) from %s thread",
"SEMAPHORE take.immediate.%s",
(options & K_USER) == K_USER ? "user" : "kernel");

PRINT_STATS_AVG(description, (uint32_t)cycles,
Expand Down
10 changes: 5 additions & 5 deletions tests/benchmarks/latency_measure/src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ int thread_ops(uint32_t num_iterations, uint32_t start_options, uint32_t alt_opt
/* Only report stats if <start_thread> created <alt_thread> */

snprintf(description, sizeof(description),
"Create %s thread from %s thread",
"THREAD create.%s.from.%s",
(alt_options & K_USER) != 0 ? "user" : "kernel",
(start_options & K_USER) != 0 ? "user" : "kernel");

Expand All @@ -261,7 +261,7 @@ int thread_ops(uint32_t num_iterations, uint32_t start_options, uint32_t alt_opt
k_sem_give(&pause_sem);

snprintf(description, sizeof(description),
"Start %s thread from %s thread",
"THREAD start.%s.from.%s",
(alt_options & K_USER) != 0 ? "user" : "kernel",
(start_options & K_USER) != 0 ? "user" : "kernel");

Expand All @@ -273,7 +273,7 @@ int thread_ops(uint32_t num_iterations, uint32_t start_options, uint32_t alt_opt
k_sem_give(&pause_sem);

snprintf(description, sizeof(description),
"Suspend %s thread from %s thread",
"THREAD suspend.%s.from.%s",
(alt_options & K_USER) != 0 ? "user" : "kernel",
(start_options & K_USER) != 0 ? "user" : "kernel");

Expand All @@ -285,7 +285,7 @@ int thread_ops(uint32_t num_iterations, uint32_t start_options, uint32_t alt_opt
k_sem_give(&pause_sem);

snprintf(description, sizeof(description),
"Resume %s thread from %s thread",
"THREAD resume.%s.from.%s",
(alt_options & K_USER) != 0 ? "user" : "kernel",
(start_options & K_USER) != 0 ? "user" : "kernel");

Expand All @@ -297,7 +297,7 @@ int thread_ops(uint32_t num_iterations, uint32_t start_options, uint32_t alt_opt
k_sem_give(&pause_sem);

snprintf(description, sizeof(description),
"Abort %s thread from %s thread",
"THREAD abort.%s.from.%s",
(alt_options & K_USER) != 0 ? "user" : "kernel",
(start_options & K_USER) != 0 ? "user" : "kernel");

Expand Down
6 changes: 3 additions & 3 deletions tests/benchmarks/latency_measure/src/thread_switch_yield.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static void thread_switch_yield_common(const char *description,
sum -= timestamp_overhead_adjustment(start_options, alt_options);

snprintf(summary, sizeof(summary),
"%s (%c -> %c)",
"%s.(%c -> %c)",
description,
(start_options & K_USER) == K_USER ? 'U' : 'K',
(alt_options & K_USER) == K_USER ? 'U' : 'K');
Expand All @@ -148,8 +148,8 @@ void thread_switch_yield(uint32_t num_iterations, bool is_cooperative)
: k_thread_priority_get(k_current_get()) - 1;

snprintf(description, sizeof(description),
"%s threads ctx switch via k_yield",
is_cooperative ? "Cooperative" : "Preemptive");
"THREAD yield.%s.ctx",
is_cooperative ? "cooperative" : "preemptive");

/* Kernel -> Kernel */
thread_switch_yield_common(description, num_iterations, 0, 0,
Expand Down

0 comments on commit 911182c

Please sign in to comment.