.NET HttpWebRequest Speed versus Browser

前端 未结 9 1120
深忆病人
深忆病人 2020-12-29 13:01

I have a question regarding the performance of the .Net HttpWebRequest client (or WebClient, gives similar results).

If I use HttpWebRequest to request an html page

9条回答
  •  感动是毒
    2020-12-29 13:30

    Whenever you measure anything, you have to account for the startup costs. If your .net code is in a single process,and you are only measuring the single request, then your measurement will be tainted by first time costs of initializing assemblies, types, etc.

    As Darin and others have suggested, you should make sure that:

    1) You are not running the process under debuggger. 2) You account for startup costs.

    One way you can do #2, is to make two requests and only measure the second one. Or you can make N requests, discard the 1st one, and get the average of last N-1 requests. Also make sure that you read the entity stream.

提交回复
热议问题