samples: subsys: zbus: benchmark: use sys_clock_cycle instead of k_uptime
Needed because benchmark finishes faster than a tick, especially on emulated platforms where tick rate is 100Hz. Output units are also updated to print numbers with less digits. Signed-off-by: Alp Sayin <alp.sayin@amd.com>
This commit is contained in:
parent
ec9c3df239
commit
560c727127
2 changed files with 13 additions and 10 deletions
|
@ -12,8 +12,8 @@ tests:
|
||||||
regex:
|
regex:
|
||||||
- "I: Benchmark 1 to 8: Dynamic memory, ASYNC transmission and message size 256"
|
- "I: Benchmark 1 to 8: Dynamic memory, ASYNC transmission and message size 256"
|
||||||
- "I: Bytes sent = 262144, received = 262144"
|
- "I: Bytes sent = 262144, received = 262144"
|
||||||
- "I: Average data rate: (.*)B/s"
|
- "I: Average data rate: (\\d+).(\\d+)MB/s"
|
||||||
- "I: Duration: (.*)ms"
|
- "I: Duration: (\\d+).(\\d+)us"
|
||||||
- "@(.*)"
|
- "@(.*)"
|
||||||
extra_configs:
|
extra_configs:
|
||||||
- CONFIG_BM_ONE_TO=8
|
- CONFIG_BM_ONE_TO=8
|
||||||
|
@ -33,8 +33,8 @@ tests:
|
||||||
regex:
|
regex:
|
||||||
- "I: Benchmark 1 to 8: Dynamic memory, SYNC transmission and message size 256"
|
- "I: Benchmark 1 to 8: Dynamic memory, SYNC transmission and message size 256"
|
||||||
- "I: Bytes sent = 262144, received = 262144"
|
- "I: Bytes sent = 262144, received = 262144"
|
||||||
- "I: Average data rate: (.*)B/s"
|
- "I: Average data rate: (\\d+).(\\d+)MB/s"
|
||||||
- "I: Duration: (.*)ms"
|
- "I: Duration: (\\d+).(\\d+)us"
|
||||||
- "@(.*)"
|
- "@(.*)"
|
||||||
extra_configs:
|
extra_configs:
|
||||||
- CONFIG_BM_ONE_TO=8
|
- CONFIG_BM_ONE_TO=8
|
||||||
|
|
|
@ -185,7 +185,7 @@ static void producer_thread(void)
|
||||||
|
|
||||||
zbus_chan_finish(&bm_channel);
|
zbus_chan_finish(&bm_channel);
|
||||||
|
|
||||||
uint32_t start = k_uptime_get_32();
|
uint32_t start_ns = k_cyc_to_ns_near32(sys_clock_cycle_get_32());
|
||||||
|
|
||||||
for (uint64_t internal_count = BYTES_TO_BE_SENT / CONFIG_BM_ONE_TO; internal_count > 0;
|
for (uint64_t internal_count = BYTES_TO_BE_SENT / CONFIG_BM_ONE_TO; internal_count > 0;
|
||||||
internal_count -= CONFIG_BM_MESSAGE_SIZE) {
|
internal_count -= CONFIG_BM_MESSAGE_SIZE) {
|
||||||
|
@ -199,18 +199,21 @@ static void producer_thread(void)
|
||||||
|
|
||||||
zbus_chan_notify(&bm_channel, K_MSEC(200));
|
zbus_chan_notify(&bm_channel, K_MSEC(200));
|
||||||
}
|
}
|
||||||
uint32_t duration = (k_uptime_get_32() - start);
|
|
||||||
|
uint32_t end_ns = k_cyc_to_ns_near32(sys_clock_cycle_get_32());
|
||||||
|
|
||||||
|
uint32_t duration = end_ns - start_ns;
|
||||||
|
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
LOG_ERR("Something wrong. Duration is zero!\n");
|
LOG_ERR("Something wrong. Duration is zero!\n");
|
||||||
k_oops();
|
k_oops();
|
||||||
}
|
}
|
||||||
uint64_t i = (BYTES_TO_BE_SENT * 1000) / duration;
|
uint64_t i = ((BYTES_TO_BE_SENT * NSEC_PER_SEC) / MB(1)) / duration;
|
||||||
uint64_t f = ((BYTES_TO_BE_SENT * 100000) / duration) % 100;
|
uint64_t f = ((BYTES_TO_BE_SENT * NSEC_PER_SEC * 100) / MB(1) / duration) % 100;
|
||||||
|
|
||||||
LOG_INF("Bytes sent = %lld, received = %llu", BYTES_TO_BE_SENT, count);
|
LOG_INF("Bytes sent = %lld, received = %llu", BYTES_TO_BE_SENT, count);
|
||||||
LOG_INF("Average data rate: %llu.%lluB/s", i, f);
|
LOG_INF("Average data rate: %llu.%lluMB/s", i, f);
|
||||||
LOG_INF("Duration: %ums", duration);
|
LOG_INF("Duration: %u.%uus", duration / NSEC_PER_USEC, duration % NSEC_PER_USEC);
|
||||||
|
|
||||||
printk("\n@%u\n", duration);
|
printk("\n@%u\n", duration);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue