Skip to content

Commit

Permalink
Get the silly benchmark framework and AesonEncode cooperating
Browse files Browse the repository at this point in the history
  • Loading branch information
bos committed Jan 9, 2014
1 parent 97635d8 commit 06d7edd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions benchmarks/AesonEncode.hs
Expand Up @@ -4,6 +4,7 @@ import Control.Exception
import Control.Monad
import Data.Aeson
import Data.Attoparsec (IResult(..), parseWith)
import Data.Char (isDigit)
import Data.Time.Clock
import System.Environment (getArgs)
import System.IO
Expand All @@ -22,7 +23,10 @@ instance NFData L.ByteString where

main :: IO ()
main = do
(cnt:args) <- getArgs
args0 <- getArgs
let (cnt,args) = case args0 of
(i:c:a) | all isDigit i && all isDigit c -> (c,a)
(c:a) -> (c,a)
let count = read cnt :: Int
forM_ args $ \arg -> bracket (openFile arg ReadMode) hClose $ \h -> do
putStrLn $ arg ++ ":"
Expand All @@ -39,5 +43,5 @@ main = do
loop 0 r0
delta <- flip diffUTCTime start `fmap` getCurrentTime
let rate = fromIntegral count / realToFrac delta :: Double
putStrLn $ " " ++ show delta
putStrLn $ " " ++ cnt ++ " good, " ++ show delta
putStrLn $ " " ++ show (round rate :: Int) ++ " per second"

0 comments on commit 06d7edd

Please sign in to comment.