@@ -1,83 +0,0 @@
1−-- This is a WIP module that shouldn't be used.
2−module Servant.QuickCheck.Internal.Benchmarking where
3−
4−import Data.ByteString (ByteString)
5−import Data.ByteString.Lazy (toStrict)
6−import Network.HTTP.Client
7−import Network.HTTP.Types
8−import Servant.Client
9−
10−data BenchOptions = BenchOptions
11− { duration :: Int
12− , threads :: Int
13− , connections :: Int
14− , noOfTests :: Int
15− } deriving (Eq, Show, Read)
16−
17−defaultBenchOptions :: BenchOptions
18−defaultBenchOptions = BenchOptions
19− { duration = 10
20− , threads = 1
21− , connections = 10
22− , noOfTests = 10
23− }
24−
25−data WrkScript = WrkScript
26− { wrkScheme :: Scheme
27− , wrkHost :: ByteString
28− , wrkPort :: Int
29− , wrkMethod :: Method
30− , wrkPath :: ByteString
31− , wrkHeaders :: [Header]
32− , wrkBody :: ByteString
33− } deriving (Eq, Show)
34−
35−mkScript :: WrkScript -> String
36−mkScript w
37− = "wrk.scheme = \"" ++ sscheme (wrkScheme w) ++ "\""
38− ++ "\nwrk.host = " ++ show (wrkHost w)
39− ++ "\nwrk.port = " ++ show (wrkPort w)
40− ++ "\nwrk.method = " ++ show (wrkMethod w)
41− ++ "\nwrk.path = " ++ show (wrkPath w)
42− ++ foldr (\(h,v) old -> old ++ "\nwrk.headers[" ++ show h ++ "] = " ++ show v)
43− ""
44− (wrkHeaders w)
45− ++ "\nwrk.body = " ++ show (wrkBody w)
46− ++ "\n" ++ reportFmt
47− where
48− sscheme Http = "http"
49− sscheme Https = "https"
50−
51−reqToWrk :: Request -> WrkScript
52−reqToWrk r = WrkScript
53− { wrkScheme = Http
54− , wrkHost = host r
55− , wrkPort = port r
56− , wrkMethod = method r
57− , wrkPath = path r
58− , wrkHeaders = requestHeaders r
59− , wrkBody = case requestBody r of
60− RequestBodyLBS r' -> toStrict r'
61− _ -> error "expecting RequestBodyLBS"
62− }
63−
64−reportFmt :: String
65−reportFmt
66− = "done = function(summary, latency, requests)\n"
67− ++ " for _, p in pairs({ 50, 75, 99, 99.999 }) do\n"
68− ++ " n = latency:percentile(p)\n"
69− ++ " io.write(string.format(\"%g%%, %d\\n\", p, n))\n"
70− ++ " end\n"
71− ++ "end\n"
72−
73−{-data BenchResult = BenchResult-}
74− {-{ benchReq :: Request-}
75− {-, benchLatencyDist :: [(Percentile, Microsecs)]-}
76− {-, benchLatencyAvg :: Microsecs-}
77− {-} deriving (Eq, Show, Read, Generic)-}
78−
79−{-newtype Microsecs = Microsecs { unMicroSecs :: Int }-}
80− {-deriving (Eq, Show, Read, Generic)-}
81−
82−{-newtype Percentile = Percentile { unPercentile :: Int }-}
83− {-deriving (Eq, Show, Read, Generic)-}