@@ -30,7 +30,6 @@ import Control.Monad.IO.Class
30
30
import Control.Monad.Trans.Except
31
31
import qualified Data.ByteString as BS
32
32
import Data.Proxy
33
- import qualified Data.TDigest as TD
34
33
import qualified Network.HTTP.Client as C
35
34
import Prelude ()
36
35
import Prelude.Compat
@@ -134,50 +133,3 @@ streamSpec = beforeAll (CT.startWaiApp server) $ afterAll CT.endWaiApp $ do
134
133
where
135
134
input = [" foo" , " " , " bar" ]
136
135
output = [" foo" , " bar" ]
137
-
138
- {-
139
- it "streams in constant memory" $ \(_, baseUrl) -> do
140
- Right rs <- runClient getGetALot baseUrl
141
- performGC
142
- -- usage0 <- getUsage
143
- -- putStrLn $ "Start: " ++ show usage0
144
- tdigest <- memoryUsage $ joinCodensitySourceT rs
145
-
146
- -- putStrLn $ "Median: " ++ show (TD.median tdigest)
147
- -- putStrLn $ "Mean: " ++ show (TD.mean tdigest)
148
- -- putStrLn $ "Stddev: " ++ show (TD.stddev tdigest)
149
-
150
- -- forM_ [0.01, 0.1, 0.2, 0.5, 0.8, 0.9, 0.99] $ \q ->
151
- -- putStrLn $ "q" ++ show q ++ ": " ++ show (TD.quantile q tdigest)
152
-
153
- let Just stddev = TD.stddev tdigest
154
-
155
- -- standard deviation of 100k is ok, we generate 256M of data after all.
156
- -- On my machine deviation is 40k-50k
157
- stddev `shouldSatisfy` (< 100000)
158
-
159
- memoryUsage :: SourceT IO BS.ByteString -> IO (TD.TDigest 25)
160
- memoryUsage src = unSourceT src $ loop mempty (0 :: Int)
161
- where
162
- loop !acc !_ Stop = return acc
163
- loop !_ !_ (Error err) = fail err -- !
164
- loop !acc !n (Skip s) = loop acc n s
165
- loop !acc !n (Effect ms) = ms >>= loop acc n
166
- loop !acc !n (Yield _bs s) = do
167
- usage <- liftIO getUsage
168
- -- We perform GC in between as we generate garbage.
169
- when (n `mod` 1024 == 0) $ liftIO performGC
170
- loop (TD.insert usage acc) (n + 1) s
171
-
172
- getUsage :: IO Double
173
- getUsage = fromIntegral .
174
- #if MIN_VERSION_base(4,10,0)
175
- gcdetails_live_bytes . gc <$> getRTSStats
176
- #else
177
- currentBytesUsed <$> getGCStats
178
- #endif
179
- memUsed `shouldSatisfy` (< megabytes 22)
180
-
181
- megabytes :: Num a => a -> a
182
- megabytes n = n * (1000 ^ (2 :: Int))
183
- -}
0 commit comments