Skip to content

feat(statistics): add machine-readable JSON output for CLI stats #4879

@SouparnaChatterjee

Description

@SouparnaChatterjee

Summary

WasmEdge currently prints statistics as human-readable [info] log lines when --enable-all-statistics is used. While useful for interactive inspection, this format is difficult to consume programmatically in benchmarking pipelines or CI systems.

This issue proposes adding a machine-readable JSON output mode for CLI statistics, for example via a flag such as:

--stats-output-json

Details

While exploring the existing statistics infrastructure and CLI implementation, I noticed that WasmEdge already exposes the required statistics internally, but the CLI currently formats them only as human-readable log output.

For benchmarking and automation workflows, structured output would make these statistics significantly easier to consume. Examples include:

-> Parsing statistics in CI pipelines
-> Benchmark regression tracking
-> Integrating with profiling dashboards
-> Processing output using tools like jq or Python scripts

Example JSON output could look like:

{
"total_execution_time_ns": 268266,
"wasm_instruction_time_ns": 251610,
"host_function_time_ns": 16656,
"instruction_count": 20425,
"gas_used": 20425,
"instructions_per_second": 81177218
}

This proposal is orthogonal to adding new statistics fields. The goal is only to expose existing statistics in a structured machine-readable format while keeping the current human-readable output unchanged.

Appendix

#4076
#4591

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Triage-required

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions