Retrieve detailed runtime statistics and block state information from a flash memory simulator instance.
MCO_RET mco_flashsim_get_stat(
/*IN*/ mco_flashsim_h fs,
/*OUT*/ mco_flashsim_stat_t *fstat,
/*OUT*/ mco_int4 *block_state
);
fs
fstat
mco_flashsim_stat_t structure that will receive aggregated I/O and timing statistics.block_state
mco_int4 values (size = number of blocks). If provided, the function fills it with the state of each erase block:
MCO_BLOCK_STATE_ERROR (–1) — block has a programming/erase error,MCO_BLOCK_STATE_BAD (–2) — block is marked as bad.NULL if block-level details are not needed.
This function collects comprehensive diagnostic data from the flash simulator, including:
- Operation counts (
n_erases,n_progs,n_reads, etc.),- Cumulative simulated time spent in I/O operations (
simulate_time),- Per-block status (erase count, error flags, bad block markers).
The statistics are **not reset** after reading — they accumulate for the lifetime of the simulator instance.
If
block_stateis provided, the caller must ensure the array is large enough to holdgeom.n_blockselements (wheregeomis the flash geometry used during initialization).
MCO_S_OK
MCO_E_INVALID_HANDLE
MCO_E_DISK
mco_flashsim_stat_t stats;
mco_int4 *block_states = NULL;
MCO_RET rc;
// Assume fs is a valid simulator handle
// and n_blocks is known from initialization params
block_states = malloc(n_blocks * sizeof(mco_int4));
rc = mco_flashsim_get_stat(fs, &stats, block_states);
if (rc == MCO_S_OK) {
printf("Total erases: %llu\n", stats.n_erases);
printf("Simulated time: %llu µs\n", stats.simulate_time);
// Inspect first block
if (block_states[0] == MCO_BLOCK_STATE_BAD) {
printf("Block 0 is marked BAD\n");
}
}
free(block_states);