MyNixOS website logo
Description

Benchmarking tool with focus on comparing results.

This tool performs lazy benchmarking of functions and shell commands with continuous feedback and improving precision.

Chronos

chronos performs lazy benchmarking of shell commands with continuous feedback and improving precision.

Please look at the documentation of the module for an overview of the api: Chronos.Bench

How does it work?

chronos will benchmark the specified commands until you abort it with ctrl-c or it reaches some termination criterion specified by the command line. It updates every iteration the measurements of the benchmarks so you can terminate it when you're satisfied with the presented precision. It will intersperse all benchmarks for fastest possible overview and to distribute any external load over all benchmarks to improve precision.

chronos

Options

chronos presents rich command line options.

options

You can as well use autocomplete of your shell with following command:

source <(chronos --bash-completion-script `which chronos`)

Normally, the output of --bash-completion-script should be coppied in the appropriate directory.

Library

You can use chronos as a haskell library to benchmark pure or impure functions or shell commands.

module Main where

import Chronos.Bench

main :: IO ()
main = defaultMain
  [ bench "fib 1" fib 1
  , bench "fib 2" fib 2
  , bench "fib 4" fib 4
  , bench "fib 8" fib 8
  ]

fib :: Int -> Int
fib 1 = 1
fib 2 = 1
fib n = fib (n-1) + fib (n-2)
module Main where

import Chronos.Bench

import Control.Concurrent
import Data.IORef

main :: IO ()
main = defaultMain
  [ benchIO "ioref" (newIORef True)
  , benchIO "mvar"  (newMVar True)
  , benchIO "qsem"  (newQSem 5)
  , benchIO "chan"  (newChan :: IO (Chan Int))
  ]
module Main where

import Chronos.Bench

main :: IO ()
main = defaultMain
  [ benchShell "sleep is slow"  "sleep 0"
  , benchShell "echo is fast"   "echo"
  , benchShell "true is faster" "true"
  ]

Comparison

Comparing chronos to bench and hyperfine:

chronos

  • intersperses all benchmarks, therefore allowing you fast comparisons
  • uses scientific notation
  • is more robust to external loads because ouf the interspersing (it will affect all benchmarks and not only some)
  • uses a number of significant digits according to the current standard error (so with time more digits are presented and not always 4 which is often the wrong thing to do)
  • uses bars with confidence intervals on the command line for easy comparison

Comparing chronos to criterion:

chronos

  • has got a much simpler api
  • can be used in testsuites
  • has got much simpler internals
  • has got less dependencies
  • doesn't measure allocations
  • doesn't measure cpu time.
Metadata

Version

0.2.0.2

Executables (1)

  • bin/chronos

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows