Commits

Bryan O'Sullivan  committed 6158a49

Get the silly benchmark framework and AesonEncode cooperating

  • Participants
  • Parent commits c22370d

Comments (0)

Files changed (1)

File benchmarks/AesonEncode.hs

 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
 
 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 ++ ":"
     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"