diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-25 00:47:43 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-25 00:47:43 +0400 |
commit | d5bae29716f894f4f9c2623455db38260664ae16 (patch) | |
tree | aa3d2cfda9ca3dde994f2eae388f42085dd8e38b /bench | |
parent | 46b6ba10202b73ba413d18bd21a284e3897c12b0 (diff) |
Update benchmarks
Diffstat (limited to 'bench')
-rw-r--r-- | bench/Main.hs | 45 | ||||
-rw-r--r-- | bench/Server.hs | 13 |
2 files changed, 22 insertions, 36 deletions
diff --git a/bench/Main.hs b/bench/Main.hs index 024d4d93..97f97425 100644 --- a/bench/Main.hs +++ b/bench/Main.hs | |||
@@ -1,33 +1,32 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | 1 | {-# LANGUAGE OverloadedStrings #-} |
2 | {-# LANGUAGE MultiParamTypeClasses #-} | ||
3 | {-# OPTIONS_GHC -fno-warn-orphans #-} | ||
2 | module Main (main) where | 4 | module Main (main) where |
3 | |||
4 | import Control.Monad | 5 | import Control.Monad |
5 | import Data.ByteString (ByteString) | 6 | import Control.Monad.Reader |
6 | import qualified Data.ByteString as B | ||
7 | import Criterion.Main | 7 | import Criterion.Main |
8 | import Data.ByteString as BS | ||
8 | import Network.KRPC | 9 | import Network.KRPC |
9 | import Network.Socket | ||
10 | 10 | ||
11 | instance KRPC ByteString ByteString where | ||
12 | method = "echo" | ||
11 | 13 | ||
12 | addr :: RemoteAddr | 14 | echo :: Handler IO |
13 | addr = SockAddrInet 6000 0 | 15 | echo = handler $ \ _ bs -> return (bs :: ByteString) |
14 | 16 | ||
15 | echo :: Method ByteString ByteString | 17 | addr :: SockAddr |
16 | echo = method "echo" ["x"] ["x"] | 18 | addr = SockAddrInet 6000 (256 * 256 * 256 + 127) |
17 | 19 | ||
18 | main :: IO () | 20 | main :: IO () |
19 | main = withRemote $ \remote -> do { | 21 | main = withManager addr [echo] $ \ m -> (`runReaderT` m) $ do |
20 | ; let sizes = [10, 100, 1000, 10000, 16 * 1024] | 22 | listen |
21 | ; let repetitions = [1, 10, 100, 1000] | 23 | liftIO $ defaultMain (benchmarks m) |
22 | ; let params = [(r, s) | r <- repetitions, s <- sizes] | ||
23 | ; let benchmarks = map (uncurry (mkbench_ remote)) params | ||
24 | ; defaultMain benchmarks | ||
25 | } | ||
26 | where | 24 | where |
27 | mkbench_ re r n = bench (show r ++ "/" ++ show n) $ nfIO $ | 25 | sizes = [10, 100, 1000, 10000, 16 * 1024] |
28 | replicateM r $ call_ re addr echo (B.replicate n 0) | 26 | repetitions = [1, 10, 100, 1000] |
29 | 27 | benchmarks m = [mkbench m r s | r <- repetitions, s <- sizes] | |
30 | {- | 28 | where |
31 | forM_ [1..] $ const $ do | 29 | mkbench m r n = |
32 | async addr myconcat (replicate 100 [1..10]) | 30 | bench (show r ++ "times" ++ "/" ++ show n ++ "bytes") $ nfIO $ |
33 | -} | 31 | replicateM r $ |
32 | runReaderT (query addr (BS.replicate n 0)) m | ||
diff --git a/bench/Server.hs b/bench/Server.hs deleted file mode 100644 index ef20c08a..00000000 --- a/bench/Server.hs +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | module Main (main) where | ||
3 | |||
4 | import Data.ByteString (ByteString) | ||
5 | import Network.KRPC | ||
6 | import Network.Socket | ||
7 | |||
8 | |||
9 | echo :: Method ByteString ByteString | ||
10 | echo = method "echo" ["x"] ["x"] | ||
11 | |||
12 | main :: IO () | ||
13 | main = server (SockAddrInet 6000 0) [ echo ==> return ] | ||