# mco_flashsim_print_stat
RT

> Print human-readable flash simulator statistics and block health map to standard output.

### Prototype

        MCO_RET mco_flashsim_print_stat(
            /*IN*/ mco_flashsim_h fs,
            /*IN*/ unsigned int blocks_per_line
        );

### Arguments

`fs`
Handle to an open flash simulator instance.
`blocks_per_line`
Number of flash blocks to display per line in the bad block map (e.g., 64, 128). Controls formatting of the visual block health report.

### Description

> This function outputs a comprehensive diagnostic report for the flash simulator to `stdout`. The report includes:

> - Aggregated I/O operation counts (reads, writes, erases, copies),
> - Total data volume transferred (in bytes and megabytes),
> - Simulated timing statistics,
> - A visual block health map using ASCII characters:
>   - `.` — healthy block,
>   - `!` — block with a programming/erase error (`MCO_BLOCK_STATE_ERROR`),
>   - `X` — block marked as bad (`MCO_BLOCK_STATE_BAD`).

> The function is intended for debugging, testing, and performance analysis. It internally calls `mco_flashsim_get_stat()` to collect data.

> Note: This function performs dynamic memory allocation for the block state array. Ensure sufficient heap space is available.

### Return Codes

`MCO_S_OK`
Statistics successfully printed.
`MCO_E_INVALID_HANDLE`
The provided simulator handle is invalid.
`MCO_E_NOMEM`
Failed to allocate memory for block state data.
`MCO_E_DISK`
Internal error occurred while accessing simulator state.

### Example

        // Print flash stats with 64 blocks per line
        MCO_RET rc = mco_flashsim_print_stat(fs, 64);
        if (rc == MCO_S_OK) {
            printf("Flash simulator report generated.\n");
        }

### Files

Header file:
mcoflashsim.h
Source file:
mcoflashsim.c
Library:
libmcoflashsim.a