diff options
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index c3c0ed15..05a3de26 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -26,6 +26,8 @@ import Text.Printf | |||
26 | import Text.Read | 26 | import Text.Read |
27 | import Control.Monad.Reader.Class | 27 | import Control.Monad.Reader.Class |
28 | import System.Posix.Process (getProcessID) | 28 | import System.Posix.Process (getProcessID) |
29 | import GHC.Stats | ||
30 | import System.Mem | ||
29 | 31 | ||
30 | import Data.Torrent (InfoHash) | 32 | import Data.Torrent (InfoHash) |
31 | import Network.BitTorrent.Address | 33 | import Network.BitTorrent.Address |
@@ -187,6 +189,38 @@ clientSession st signalQuit sock n h = do | |||
187 | tm <- getCurrentTime | 189 | tm <- getCurrentTime |
188 | let r = map (\PerThread{..} -> (show lbl,show (diffUTCTime tm startTime))) ts | 190 | let r = map (\PerThread{..} -> (show lbl,show (diffUTCTime tm startTime))) ts |
189 | hPutClient h $ showReport r | 191 | hPutClient h $ showReport r |
192 | ("mem", s) -> cmd $ return $ do | ||
193 | case s of | ||
194 | "gc" -> do hPutClient h "Performing garbage collection..." | ||
195 | performMajorGC | ||
196 | "" -> do | ||
197 | is_enabled <- getGCStatsEnabled | ||
198 | if is_enabled | ||
199 | then do | ||
200 | GCStats{..} <- getGCStats | ||
201 | let r = [ ("bytesAllocated", show bytesAllocated) | ||
202 | , ("numGcs", show numGcs) | ||
203 | , ("maxBytesUsed", show maxBytesUsed) | ||
204 | , ("numByteUsageSamples", show numByteUsageSamples) | ||
205 | , ("cumulativeBytesUsed", show cumulativeBytesUsed) | ||
206 | , ("bytesCopied", show bytesCopied) | ||
207 | , ("currentBytesUsed", show currentBytesUsed) | ||
208 | , ("currentBytesSlop", show currentBytesSlop) | ||
209 | , ("maxBytesSlop", show maxBytesSlop) | ||
210 | , ("peakMegabytesAllocated", show peakMegabytesAllocated) | ||
211 | , ("mutatorCpuSeconds", show mutatorCpuSeconds) | ||
212 | , ("mutatorWallSeconds", show mutatorWallSeconds) | ||
213 | , ("gcCpuSeconds", show gcCpuSeconds) | ||
214 | , ("gcWallSeconds", show gcWallSeconds) | ||
215 | , ("cpuSeconds", show cpuSeconds) | ||
216 | , ("wallSeconds", show wallSeconds) | ||
217 | , ("parTotBytesCopied", show parTotBytesCopied) | ||
218 | , ("parMaxBytesCopied", show parMaxBytesCopied) | ||
219 | ] | ||
220 | hPutClient h $ showReport r | ||
221 | else hPutClient h "Run with +RTS -T to obtain live memory-usage information." | ||
222 | _ -> hPutClient h "error." | ||
223 | |||
190 | #endif | 224 | #endif |
191 | ("closest", s) -> cmd $ do | 225 | ("closest", s) -> cmd $ do |
192 | let (ns,hs) = second (dropWhile isSpace) $ break isSpace s | 226 | let (ns,hs) = second (dropWhile isSpace) $ break isSpace s |