diff options
author | James Crayne <jim.crayne@gmail.com> | 2019-09-28 13:43:29 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:27:53 -0500 |
commit | 11987749fc6e6d3e53ea737d46d5ab13a16faeb8 (patch) | |
tree | 5716463275c2d3e902889db619908ded2a73971c /bittorrent/bench/Throughtput.hs | |
parent | add2c76bced51fde5e9917e7449ef52be70faf87 (diff) |
Factor out some new libraries
word64-map:
Data.Word64Map
network-addr:
Network.Address
tox-crypto:
Crypto.Tox
lifted-concurrent:
Control.Concurrent.Lifted.Instrument
Control.Concurrent.Async.Lifted.Instrument
psq-wrap:
Data.Wrapper.PSQInt
Data.Wrapper.PSQ
minmax-psq:
Data.MinMaxPSQ
tasks:
Control.Concurrent.Tasks
kad:
Network.Kademlia
Network.Kademlia.Bootstrap
Network.Kademlia.Routing
Network.Kademlia.CommonAPI
Network.Kademlia.Persistence
Network.Kademlia.Search
Diffstat (limited to 'bittorrent/bench/Throughtput.hs')
-rw-r--r-- | bittorrent/bench/Throughtput.hs | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/bittorrent/bench/Throughtput.hs b/bittorrent/bench/Throughtput.hs deleted file mode 100644 index d0404405..00000000 --- a/bittorrent/bench/Throughtput.hs +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | {-# LANGUAGE ViewPatterns #-} | ||
2 | {-# LANGUAGE PatternGuards #-} | ||
3 | module Main (main) where | ||
4 | |||
5 | import Control.Concurrent | ||
6 | import Data.Bitfield | ||
7 | import Network.BitTorrent | ||
8 | import System.Environment | ||
9 | import Control.Monad.Reader | ||
10 | import Data.IORef | ||
11 | |||
12 | |||
13 | main :: IO () | ||
14 | main = do | ||
15 | [path] <- getArgs | ||
16 | torrent <- fromFile path | ||
17 | |||
18 | print (contentLayout "./" (tInfo torrent)) | ||
19 | |||
20 | client <- newClient 100 [] | ||
21 | swarm <- newLeecher client torrent | ||
22 | |||
23 | ref <- liftIO $ newIORef 0 | ||
24 | discover swarm $ do | ||
25 | forever $ do | ||
26 | e <- awaitEvent | ||
27 | case e of | ||
28 | Available bf | ||
29 | | Just m <- findMin bf -> yieldEvent (Want (BlockIx m 0 10)) | ||
30 | | otherwise -> return () | ||
31 | Want bix -> liftIO $ print bix | ||
32 | Fragment blk -> do | ||
33 | |||
34 | sc <- liftIO $ getSessionCount swarm | ||
35 | addr <- asks connectedPeerAddr | ||
36 | |||
37 | liftIO $ do | ||
38 | x <- atomicModifyIORef ref (\x -> (succ x, x)) | ||
39 | if x `mod` 100 == 0 | ||
40 | then print (x, sc, addr) | ||
41 | else return () | ||
42 | |||
43 | yieldEvent (Want (BlockIx 0 0 (16 * 1024))) | ||
44 | |||
45 | |||
46 | print "Bye-bye! =_=" \ No newline at end of file | ||