golds-gym-0.7.0.0: Golden testing framework for performance benchmarks
Copyright(c) 2026
LicenseMIT
Maintainer@ocramz
Safe HaskellNone
LanguageHaskell2010

Test.Hspec.BenchGolden.CSV

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 parameter
  • param_value - The value of the parameter for this row
  • mean_ms - Mean execution time in milliseconds
  • stddev_ms - Standard deviation in milliseconds
  • median_ms - Median execution time in milliseconds
  • min_ms - Minimum execution time in milliseconds
  • max_ms - Maximum execution time in milliseconds
  • trimmed_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

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