Skip to content

Export raw samples to CSV and JSON for external analysis #12

Description

@fior512

Motivation

DumpToStream produces a human-readable ANSI table, but users often need to feed data into Python (pandas, matplotlib), R, or a Grafana dashboard. Without an export path they have to screen-scrape the report, which is fragile.

Proposed API

Two free functions / overloads in the Latte:: namespace:

// CSV: one row per sample, columns: thread_id, id_label, cycles, ns
void DumpCSV(std::ostream& out, Parameter unit = Parameter::Time);

// JSON: structured object per ID with raw array + summary stats
void DumpJSON(std::ostream& out, Parameter unit = Parameter::Time);

CSV format

id,thread,sample_ns
"order_send",0,482
"order_send",0,491
"order_send",1,478

JSON format

{
  "order_send": {
    "count": 3000,
    "threads": [0, 2, 3, ...]
    "samples_ns": [482, 491, 478, ...]
  }
}

Acceptance Criteria

  • DumpCSV(ostream, unit) implemented using only <sstream> / <string> (no external deps)
  • DumpJSON(ostream, unit) likewise
  • Both functions aggregate across all threads (same as ExtractRaw)
  • Both respect Parameter::Calibrated flag
  • LATTE_DISABLE stubs them out to no-ops
  • README example showing pipe-to-file pattern: Latte::DumpCSV(std::ofstream("out.csv"))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions