Skip to content

Commit ee1a4c2

Browse files
committed
AP_Logger: add flash speed test
1 parent d0c9a76 commit ee1a4c2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

libraries/AP_Logger/AP_Logger_Block.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ void AP_Logger_Block::write_log_page()
926926

927927
void AP_Logger_Block::flash_test()
928928
{
929-
const uint32_t pages_to_check = 128;
929+
uint32_t pages_to_check = 128;
930930
for (uint32_t i=1; i<=pages_to_check; i++) {
931931
if ((i-1) % df_PagePerBlock == 0) {
932932
printf("Block erase %u\n", get_block(i));
@@ -962,6 +962,19 @@ void AP_Logger_Block::flash_test()
962962
i, bad_bytes, df_PageSize, buffer[first_bad_byte]);
963963
}
964964
}
965+
966+
// speed test
967+
pages_to_check = 4096; // 1mB / 8mB
968+
for (uint32_t i=1; i<=pages_to_check; i++) {
969+
if ((i-1) % df_PagePerBlock == 0) {
970+
SectorErase(get_block(i));
971+
}
972+
}
973+
uint32_t now_ms = AP_HAL::millis();
974+
for (uint32_t i=1; i<=pages_to_check; i++) {
975+
BufferToPage(i);
976+
}
977+
printf("Flash speed test: %ukB/s\n", unsigned((pages_to_check * df_PageSize * 1000) / (1024 * (AP_HAL::millis() - now_ms))));
965978
}
966979

967980
#endif // HAL_LOGGING_BLOCK_ENABLED

0 commit comments

Comments
 (0)