packages feed

burst-detection-1.0: benchmark/Main.hs

{-# LANGUAGE BangPatterns #-}
-- |
-- Copyright : (C) 2013 Parallel Scientific Labs, LLC.
-- License   : GPLv2
--
-- Burst prototype based on the work of Jonathan Jouty.
--
module Main
  where

import Math.Bursts

import Criterion.Main
import Criterion.Measurement
import Control.Monad ( void )
import Control.Exception ( evaluate )
import Text.Printf


main = do
    defaultMain 
      [ bgroup "burst" 
          [ bench "depth 18" $ nf go 18
          ]
      ]
    let samples = 20
    d <- time_ $ void . evaluate $ go samples
    printf "Samples per second: %14.4f\n"   $ (fromIntegral samples)/d
    printf "Nanoseconds per sample: %.4f\n" $ d/(fromIntegral samples)*1e9
  where
    go n = sbtBurstAnalysisMany ([0..n]) w
    w :: Window Int
    w = initialWindow 4096 10 100 defaultAggregate