[Haskell-cafe] ANN: benchpress 0.2.1

Johan Tibell johan.tibell at gmail.com
Tue Aug 19 02:49:42 EDT 2008


I'm pleased to announce the first public release of benchpress.

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/benchpress

benchpress is a micro-benchmark library that produces statistics such
as min, mean, standard deviation, median, and max execution time. It
also computes execution time percentiles.

Release bundle:
  http://hackage.haskell.org/packages/archive/benchpress/0.2.1/benchpress-0.2.1.tar.gz

Docs:
  http://hackage.haskell.org/packages/archive/benchpress/0.2.1/doc/html/Test-BenchPress.html

Code:
  git clone git://github.com/tibbe/benchpress.git

An example benchmark:

> import qualified Data.ByteString as B
> import System.IO
> import Test.BenchPress
>
> inpath, outpath :: String
> inpath = "/tmp/infile"
> outpath = "/tmp/outfile"
>
> blockSize :: Int
> blockSize = 4 * 1024
>
> copyUsingByteString :: Handle -> Handle -> IO ()
> copyUsingByteString inf outf = go
>     where
>       go = do
>         bs <- B.hGet inf blockSize
>         let numRead = B.length bs
>         if numRead > 0
>            then B.hPut outf bs >> go
>            else return ()
>
> main :: IO ()
> main = bench 100 $ do
>          inf <- openBinaryFile inpath ReadMode
>          outf <- openBinaryFile outpath WriteMode
>          copyUsingByteString inf outf
>          hClose outf
>          hClose inf

And the output, best viewed using a fixed-width font:

$ ./example
Times (ms)
   min      mean    +/-sd    median    max
 232.774  273.611   53.317  266.648  722.332

Percentiles (ms)
  50%  266.644
  66%  266.826
  75%  269.616
  80%  295.040
  90%  295.360
  95%  305.855
  98%  350.742
  99%  450.855
 100%  722.332

Cheers,

Johan


More information about the Haskell-Cafe mailing list