@@ -3,7 +3,7 @@ module Main where
33import Network.Transport
44import Network.Transport.TCP (mkTransport, TCPConfig (..))
55
6−import Control.Monad (forever)
6+import Control.Monad (forever, replicateM_)
77import Criterion.Main (Benchmark, bench, defaultMain, nfIO)
88import Data.Binary
99import Data.Maybe (fromJust)
@@ -77,9 +77,9 @@ pong targetEndPing sourceEndPong = do
7777-- | The effect of `ping sourceEndPing targetEndPong n` is to send the number
7878-- `n` using `sourceEndPing`, and to then receive the a number from
7979-- `targetEndPong`, which is then returned.
80−ping :: SourceEnd -> TargetEnd -> Int64 -> IO Int64
81−ping sourceEndPing targetEndPong n = do
82− send sourceEndPing [encode n]
80+ping :: SourceEnd -> TargetEnd -> IO Int64
81+ping sourceEndPing targetEndPong = do
82+ send sourceEndPing [BS.empty]
8383 [bs] <- receive targetEndPong
8484 return $ decode bs
8585
@@ -88,5 +88,5 @@ ping sourceEndPing targetEndPong n = do
8888-- taken is benchmarked.
8989benchPing :: SourceEnd -> TargetEnd -> Int64 -> Benchmark
9090benchPing sourceEndPing targetEndPong n = bench "Transport Ping" $
91− nfIO (mapM_ (ping sourceEndPing targetEndPong) [1 .. n])
91+ nfIO (replicateM_ (fromIntegral n) (ping sourceEndPing targetEndPong))
9292