
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.... Docs: http://hackage.haskell.org/packages/archive/benchpress/0.2.1/doc/html/Test-B... 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

On Tue, Aug 19, 2008 at 8:49 AM, Johan Tibell
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.
Nice, I'm certainty going to use this. Thanks! It would be even nicer if you could also measure the elapsed CPU time (using System.CPUTime.getCPUTime). Than the measurement is not influenced by time spent in other processes and IO time. regards, Bas

On Tue, Aug 19, 2008 at 9:37 AM, Bas van Dijk
On Tue, Aug 19, 2008 at 8:49 AM, Johan Tibell
wrote: 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.
Nice, I'm certainty going to use this. Thanks!
It would be even nicer if you could also measure the elapsed CPU time (using System.CPUTime.getCPUTime). Than the measurement is not influenced by time spent in other processes and IO time.
Thanks. I will ponder how to best expose this in the interface. An option would be to return a tuple of Stats records where the first component is the wall clock time and the second is the CPU time. I might have to run the action twice to avoid extra measuring overhead. For example, in startCpu <- getCPUTime startWall <- getCurrentTime action endWall <- getCurrentTime endCpu <- getCPUTime the measured time includes the two calls to getCurrentTime. Running the action twice will double the benchmark running time which might or might not matter. Cheers, Johan

On Tue, Aug 19, 2008 at 10:54 AM, Johan Tibell
I will ponder how to best expose this in the interface.
Nice
I might have to run the action twice to avoid extra measuring overhead.
I don't think it matters because the extra measuring overhead is constant over the measuring iterations. Bas

On Tue, Aug 19, 2008 at 2:14 PM, Bas van Dijk
On Tue, Aug 19, 2008 at 10:54 AM, Johan Tibell
wrote: I might have to run the action twice to avoid extra measuring overhead.
I don't think it matters because the extra measuring overhead is constant over the measuring iterations.
I want the reported times to differ as little as possible from the actual running times. Any constant overhead skews the results upwards. It might matter is the action being benchmark has a very low run time. Maybe I misunderstood what you said. -- Johan

On Tue, Aug 19, 2008 at 9:37 AM, Bas van Dijk
On Tue, Aug 19, 2008 at 8:49 AM, Johan Tibell
wrote: 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.
Nice, I'm certainty going to use this. Thanks!
It would be even nicer if you could also measure the elapsed CPU time (using System.CPUTime.getCPUTime). Than the measurement is not influenced by time spent in other processes and IO time.
Available in 0.2.2 on Hackage. Cheers, Johan
participants (2)
-
Bas van Dijk
-
Johan Tibell