Package

purescript-benchlib

Repository
m-bock/purescript-benchlib
License
BSD-3-Clause
Uploaded by
pacchettibotti
Published on
2025-04-16T06:31:11Z

A simple and flexible benchmarking library for PureScript.

Features

  • Customizable Output – Choose between console logging, JSON reports, HTML or Markdown summaries with rendered charts.

  • Flexible Benchmarking – Configure iterations, input sizes, and setup functions.

  • Supports Pure & Effectful Functions – Benchmark any kind of computation.

  • Just PureScript – No JavaScript libraries under the hood, ensuring full type safety.


Focus on writing benchmarks, not boilerplate.

Limitations

  • Currently, the library only supports Node.js. However, it's planned to add browser support in the future.

  • The library is still in its early stages, and we welcome contributions to improve it.

Example to Get You Started

1 . Define Benchmarks in PureScript

module Test.Samples.Minimal where

import Prelude

import BenchLib (basic, group_, suite_, bench_)
import BenchLib as BenchLib
import Data.Array as Array
import Data.List.Lazy as LazyList
import Effect (Effect)

--- Main

main :: Effect Unit
main = BenchLib.runNode_ $
  suite_
    "Minimal Example"
    [ group_ "Replicate Functions"
        [ basic $ bench_
            "Array"
            identity
            (\size -> Array.replicate size 'x')

        , basic $ bench_
            "Lazy List"
            identity
            (\size -> LazyList.replicate size 'x')
        ]
    ]

2. Run Benchmarks from Terminal

After defining your benchmarks, you can run them from the terminal using spago:

spago run -m Test.Samples.Minimal
Modules
BenchLib
BenchLib.Reporters.Html
BenchLib.Reporters.Json
BenchLib.Reporters.Markdown
Dependencies