Skip to content

Commit 659a8c6

Browse files
authored
Remove commented code and unused dependency (tdigest) (#1667)
1 parent 67168f0 commit 659a8c6

File tree

3 files changed

+0
-50
lines changed

3 files changed

+0
-50
lines changed

servant-client/servant-client.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ test-suite spec
130130
, QuickCheck >= 2.12.6.1 && < 2.15
131131
, servant == 0.19.*
132132
, servant-server == 0.19.*
133-
, tdigest >= 0.2 && < 0.3
134133

135134
build-tool-depends:
136135
hspec-discover:hspec-discover >= 2.6.0 && < 2.10

servant-client/test/Servant/StreamSpec.hs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import Control.Monad.IO.Class
3030
import Control.Monad.Trans.Except
3131
import qualified Data.ByteString as BS
3232
import Data.Proxy
33-
import qualified Data.TDigest as TD
3433
import qualified Network.HTTP.Client as C
3534
import Prelude ()
3635
import Prelude.Compat
@@ -134,50 +133,3 @@ streamSpec = beforeAll (CT.startWaiApp server) $ afterAll CT.endWaiApp $ do
134133
where
135134
input = ["foo", "", "bar"]
136135
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-
-}

servant-http-streams/servant-http-streams.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ test-suite spec
118118
, QuickCheck >= 2.12.6.1 && < 2.15
119119
, servant == 0.19.*
120120
, servant-server == 0.19.*
121-
, tdigest >= 0.2 && < 0.3
122121

123122
build-tool-depends:
124123
hspec-discover:hspec-discover >= 2.6.0 && < 2.10

0 commit comments

Comments
 (0)