Skip to content
Newer
Older
100644 35 lines (31 sloc) 1002 Bytes
3568e5e @bos More benchmarkery: try out the json library.
authored Jan 26, 2011
1 {-# LANGUAGE BangPatterns, ScopedTypeVariables #-}
6810039 @bos Build Haskell benchmarks with cabal
authored Dec 22, 2011
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
809740f @bos Add new simple benchmarks
authored Jan 25, 2011
3
4b9b9e0 @bos Add an NFData instance for Value
authored Jan 25, 2011
4 import Control.DeepSeq
809740f @bos Add new simple benchmarks
authored Jan 26, 2011
5 import Control.Monad
3568e5e @bos More benchmarkery: try out the json library.
authored Jan 27, 2011
6 import Text.JSON
809740f @bos Add new simple benchmarks
authored Jan 26, 2011
7 import Data.Time.Clock
8 import System.Environment (getArgs)
9 import System.IO
10
3568e5e @bos More benchmarkery: try out the json library.
authored Jan 27, 2011
11 instance NFData JSValue where
12 rnf JSNull = ()
13 rnf (JSBool b) = rnf b
14 rnf (JSRational b r) = rnf b `seq` rnf r `seq` ()
15 rnf (JSString s) = rnf (fromJSString s)
16 rnf (JSArray vs) = rnf vs
17 rnf (JSObject kvs) = rnf (fromJSObject kvs)
18
809740f @bos Add new simple benchmarks
authored Jan 26, 2011
19 main = do
20 (cnt:args) <- getArgs
21 let count = read cnt :: Int
3568e5e @bos More benchmarkery: try out the json library.
authored Jan 27, 2011
22 forM_ args $ \arg -> do
809740f @bos Add new simple benchmarks
authored Jan 26, 2011
23 putStrLn $ arg ++ ":"
24 start <- getCurrentTime
25 let loop !good !bad
26 | good+bad >= count = return (good, bad)
27 | otherwise = do
3568e5e @bos More benchmarkery: try out the json library.
authored Jan 27, 2011
28 s <- readFile arg
29 case decodeStrict s of
30 Ok (v::JSValue) -> loop (good+1) 0
31 _ -> loop 0 (bad+1)
809740f @bos Add new simple benchmarks
authored Jan 26, 2011
32 (good, _) <- loop 0 0
33 end <- getCurrentTime
34 putStrLn $ " " ++ show good ++ " good, " ++ show (diffUTCTime end start)
Something went wrong with that request. Please try again.