Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crc32: Buffer up log output to avoid prefix-chunking, fix func #1998

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,28 @@ bool bmd_crc32(target_s *const target, uint32_t *const result, const uint32_t ba
#if !defined(STM32F0) && !defined(STM32F1) && !defined(STM32F2) && !defined(STM32F3) && !defined(STM32F4) && \
!defined(STM32F7) && !defined(STM32L0) && !defined(STM32L1) && !defined(STM32G0) && !defined(STM32G4)
const bool status = generic_crc32(target, result, base, len);
const char *const func = "generic_crc32";
#else
const bool status = stm32_crc32(target, result, base, len);
const char *const func = "stm32_crc32";
#endif
#ifndef DEBUG_INFO_IS_NOOP
/* "generic_crc32: 08000110+75272 -> 1353ms, 54 KiB/s" */
/* "stm32_crc32: 08000110+75272 -> 237ms, 310 KiB/s" */
/* "generic_crc32: 0x08000110+75272 -> 1353ms, 54 KiB/s" */
/* "stm32_crc32: 0x08000110+75272 -> 237ms, 310 KiB/s" */
const uint32_t end_time = platform_time_ms();
const uint32_t time_elapsed = end_time - start_time;
DEBUG_INFO("%s: 0x%08" PRIx32 "+%" PRIu32 " -> %" PRIu32 "ms", __func__, base, (uint32_t)len, time_elapsed);
if (len >= 512U) {
char logbuf[64] = {0};
const size_t logcap = 64;
size_t loglen = 0;
loglen = snprintf(&logbuf[loglen], logcap, "%s: 0x%08" PRIx32 "+%" PRIu32 " -> %" PRIu32 "ms", func, base,
(uint32_t)len, time_elapsed);
if (len >= 512U && time_elapsed > 0U) {
const uint32_t speed = len * 1000U / time_elapsed / 1024U;
DEBUG_INFO(", %" PRIu32 " KiB/s", speed);
loglen += snprintf(&logbuf[loglen], logcap - loglen, ", %" PRIu32 " KiB/s", speed);
}
DEBUG_INFO("\n");
DEBUG_INFO("%s\n", logbuf);
#else
(void)func;
#endif
return status;
}
Loading