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