| Copyright | (c) 2026 |
|---|---|
| License | MIT |
| Maintainer | @ocramz |
| Safe Haskell | None |
| Language | Haskell2010 |
Test.Hspec.BenchGolden.CSV
Contents
Description
This module provides CSV export functionality for parameter sweep benchmarks. CSV files are written alongside golden files for convenient analysis and plotting.
CSV Format
The CSV includes columns for:
timestamp- When the benchmark was run (ISO 8601 format)param_name- The name of the sweep parameterparam_value- The value of the parameter for this rowmean_ms- Mean execution time in millisecondsstddev_ms- Standard deviation in millisecondsmedian_ms- Median execution time in millisecondsmin_ms- Minimum execution time in millisecondsmax_ms- Maximum execution time in millisecondstrimmed_mean_ms- Trimmed mean (if robust statistics enabled)mad_ms- Median absolute deviation (if robust statistics enabled)iqr_ms- Interquartile range (if robust statistics enabled)
Usage
CSV files are automatically generated when using benchGoldenSweep or
benchGoldenSweepWith. The file is written to:
<outputDir>/<sweep-name>-<arch-id>.csv
For example: .golden/sort-scaling-aarch64-darwin-Apple_M1.csv
Synopsis
- csvHeader :: Text -> Builder
- csvRow :: Text -> GoldenStats -> Builder
- buildCSV :: Text -> [(Text, GoldenStats)] -> Builder
- writeSweepCSV :: FilePath -> Text -> String -> Text -> [(Text, GoldenStats)] -> IO ()
- getSweepCSVPath :: FilePath -> Text -> String -> FilePath
CSV Generation
csvHeader :: Text -> Builder Source #
Generate CSV header row.
The header includes all standard statistics columns plus a parameter column.
csvRow :: Text -> GoldenStats -> Builder Source #
Generate a single CSV data row from benchmark stats.
The timestamp is taken from the GoldenStats, and the parameter value
is provided separately as a string representation.
buildCSV :: Text -> [(Text, GoldenStats)] -> Builder Source #
Build complete CSV content from a list of (param value, stats) pairs.
Example:
let results = [("1000", stats1), ("5000", stats2), ("10000", stats3)]
let csv = buildCSV "n" results
File I/O
writeSweepCSV :: FilePath -> Text -> String -> Text -> [(Text, GoldenStats)] -> IO () Source #
Write sweep results to a CSV file.
This creates the output directory if it doesn't exist and writes the complete CSV content atomically.
getSweepCSVPath :: FilePath -> Text -> String -> FilePath Source #
Get the path for a sweep CSV file.
The file is placed in the output directory with the architecture ID included in the filename (not as a subdirectory) for easy comparison across architectures.
Example: .golden/sort-scaling-aarch64-darwin-Apple_M1.csv