dimanche 27 mars 2016

Why does the first call to WebClient.UploadString after program restart is so slow?

I have app that tests response time of my WCF service. It is doing so by next simplified code:

        const string jsonInput = "{}";
        var client = new WebClient();
        client.Headers["Content-type"] = "application/json";
        client.Encoding = Encoding.UTF8;

        Stopwatch watch = Stopwatch.StartNew();
        var response = client.UploadString("http://localhost:8080/WCFServices/GetSettings", "POST", jsonInput);
        watch.Stop();

After app restart first call to client.UploadString is very slow > 80ms. And all other calls (there can be even 3000 calls) - are very fast <2ms. And every time after testing program restart first call to UploadString is slow. Why?




Aucun commentaire:

Enregistrer un commentaire