Why is my https getter in Haskell so slow compared to curl? -
i'm writing simple https getter code in haskell. after response save file compression. version slow compared curl , gzip combination. how can make faster curl? details below.
haskell code (fetcher.hs):
import control.lens import qualified codec.compression.gzip gzip import qualified data.bytestring.lazy bl import network.wreq writeuribodytofile :: filepath -> string -> io() writeuribodytofile filepath uri = response <- uri let body = (response ^. responsebody) bl.writefile filepath (gzip.compress body) main :: io () main = writeuribodytofile "out.html.gz" "https://www.sahibinden.com/ilan/vasita-otomobil-seat-hatasiz-boyasiz-tramersiz-dsg-leon-469484363/detay/"
haskell result:
$ ghc -o fetcher fetcher.hs $ time ./fetcher real 0m9.240s user 0m8.840s sys 0m0.232s
curl result:
$ time curl "https://www.sahibinden.com/ilan/vasita-otomobil-seat-hatasiz-boyasiz-tramersiz-dsg-leon-469484363/detay/" | gzip > out.html.gz % total % received % xferd average speed time time time current dload upload total spent left speed 100 102k 100 102k 0 0 331k 0 --:--:-- --:--:-- --:--:-- 332k real 0m0.524s user 0m0.156s sys 0m0.040s
edit: tried http-conduit package, nothing changed.
import qualified data.bytestring.lazy bl import network.http.simple main :: io () main = response <- httplbs "https://www.sahibinden.com/ilan/vasita-otomobil-seat-hatasiz-boyasiz-tramersiz-dsg-leon-469484363/detay/" bl.writefile "outnew.html" $ getresponsebody response
edit2: checked connection tcpdump, , there no connection issue.
edit3: ghci, version 7.10.3
edit4: compile command ghc -o fetcher fetcher.hs
Comments
Post a Comment