lue-bird/elm-alternative-benchmark-runner/1.0.0

Benchmark.Status.Alternative

Alternative way of representing the status of a benchmark.

fromReport : Report -> Status

Convert a Benchmark.Reporting.Report to a Benchmark.Status.Alternative.Status.

fromBenchmark : Benchmark -> Status

Report the Status of a benchmark. Short for

benchmark
    |> Report.fromBenchmark
    |> Benchmark.Status.Alternative.fromReport

Instead of

type Status
    = Cold
    | Unsized
    | Pending Int Samples
    | Failure Error
    | Success Samples (Trend Quick)

the status is

type Status
= Running Running (Structure {})
| Finished (Structure { result : Result })

State of a benchmark: Finished or still Running.

when Running

type Running
= WarmingJit
| FindingSampleSize
| CollectingSamples Float

Status of a running benchmark.

  • WarmingJit: We have not warmed up the JIT yet.
  • FindingSampleSize: We have not yet determined the best sample size for this benchmark.
  • CollectingSamples: We are in the process of collecting sample data. We will keep collecting sample data until we have enough samples. The argument (between 0 and 1) shows the progress.

when Finished

type alias Result =
Result Error (Trend Quick)

Information about a finished benchmark.

  • Ok: We finished collecting all our sample data and calculated a trend using this data.
  • Err: We ran into an exception while collecting sample data. The attached Error tells us what went wrong.

utils

runsPerSecond : Trend a_ -> Float

Predict the amount of runs / 1 second.

results : Structure { result : Result } -> List Result

Collect all results.

lowestGoodnessOfFit =
    results
        >> List.filterMap Result.toMaybe
        >> List.map Trend.goodnessOfFit
        >> List.minimum
        >> Maybe.withDefault 1


errors =
    results
        >> List.filterMap
            (\result ->
                case result of
                    Err err ->
                        Just err


                    Ok _ ->
                        Nothing
            )

structure

type alias Structure status =
{ name : String
, structureKind : StructureKind status
}

The name and structure of a specific Benchmark.

  • when running: Structure {}
  • when finished: Structure { result : Result }, see Result
type StructureKind status
= Single status
| Group (List (Structure status))
| Series (List { status | name : String })

The structure type of a specific Benchmark.

–

  • when running: StructureKind {}
  • when finished: StructureKind { result : Result }, see Result