summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-25 00:47:43 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-25 00:47:43 +0400
commitd5bae29716f894f4f9c2623455db38260664ae16 (patch)
treeaa3d2cfda9ca3dde994f2eae388f42085dd8e38b /bench
parent46b6ba10202b73ba413d18bd21a284e3897c12b0 (diff)
Update benchmarks
Diffstat (limited to 'bench')
-rw-r--r--bench/Main.hs45
-rw-r--r--bench/Server.hs13
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 #-}
2module Main (main) where 4module Main (main) where
3
4import Control.Monad 5import Control.Monad
5import Data.ByteString (ByteString) 6import Control.Monad.Reader
6import qualified Data.ByteString as B
7import Criterion.Main 7import Criterion.Main
8import Data.ByteString as BS
8import Network.KRPC 9import Network.KRPC
9import Network.Socket
10 10
11instance KRPC ByteString ByteString where
12 method = "echo"
11 13
12addr :: RemoteAddr 14echo :: Handler IO
13addr = SockAddrInet 6000 0 15echo = handler $ \ _ bs -> return (bs :: ByteString)
14 16
15echo :: Method ByteString ByteString 17addr :: SockAddr
16echo = method "echo" ["x"] ["x"] 18addr = SockAddrInet 6000 (256 * 256 * 256 + 127)
17 19
18main :: IO () 20main :: IO ()
19main = withRemote $ \remote -> do { 21main = 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 #-}
2module Main (main) where
3
4import Data.ByteString (ByteString)
5import Network.KRPC
6import Network.Socket
7
8
9echo :: Method ByteString ByteString
10echo = method "echo" ["x"] ["x"]
11
12main :: IO ()
13main = server (SockAddrInet 6000 0) [ echo ==> return ]