{"id":730,"date":"2017-07-26T20:32:30","date_gmt":"2017-07-26T18:32:30","guid":{"rendered":"http:\/\/haos.hopto.org\/blog\/?p=730"},"modified":"2019-12-24T10:18:30","modified_gmt":"2019-12-24T09:18:30","slug":"kodowanie-asynchroniczne-w-csharp-na-webie","status":"publish","type":"post","link":"https:\/\/haos.hopto.org\/blog\/2017\/07\/26\/kodowanie-asynchroniczne-w-csharp-na-webie\/","title":{"rendered":"Kodowanie asynchroniczne w C# na web-ie, czyli czemu w ko\u0144cu przydadz\u0105 si\u0119 procesory wielordzeniowe"},"content":{"rendered":"\n<p>No dobra, po epokowej przerwie (ostatnio wpis jakie\u015b 4 lata temu?!!) mam co\u015b ciekawego.<\/p>\n\n\n\n<p>Szybki up-to-date, wkr\u0119ci\u0142em si\u0119 w nowego &#8222;dotneta&#8221; (.NET core) a \u015bci\u015blej <a href=\"https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/\">ASP.NET Core<\/a>.<\/p>\n\n\n\n<p>Jak zwykle przegl\u0105daj\u0105c czelu\u015bcie internetu trafi\u0142em tutaj:&nbsp;<a href=\"https:\/\/caleblloyd.com\/software\/net-core-mvc-thread-pool-vs-async\/\">https:\/\/caleblloyd.com\/software\/net-core-mvc-thread-pool-vs-async\/<\/a><\/p>\n\n\n\n<p>Wiedzia\u0142em \u017ce s\u0142owo kluczowe async, await w programowaniu us\u0142ug sieciowych w C# musi mie\u0107 jaki\u015b wi\u0119kszy sens i tre\u015b\u0107 i oto wyt\u0142umaczenie. No wi\u0119c nie by\u0142bym sob\u0105 gdybym nie zma\u015bci\u0142 jakiego\u015b benchmarka. Postanowi\u0142em za autorem u\u017cy\u0107 podobnego scenariusza i przetestowa\u0107 metody (kod ASP.NET core WebAPI):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ GET api\/values\/sleep\n&#x5B;HttpGet(&quot;sleep&quot;)]\npublic string GetSleep()\n{\n    Thread.Sleep(1000);\n    return Process.GetCurrentProcess().Threads.Count.ToString();\n}\n\n\/\/ GET api\/values\/delay\n&#x5B;HttpGet(&quot;delay&quot;)]\nasync public Task&lt;string&gt; GetDelay()\n{\n    await Task.Delay(1000);\n    return Process.GetCurrentProcess().Threads.Count.ToString();\n}\n<\/pre><\/pre>\n\n\n\n<p>No i dobra, ale przyda\u0142by si\u0119 jaki\u015b kod testowy C# a nie odwo\u0142anie (jak caleblloyd) do pakietu stress-testuj\u0105cego. No to wymy\u015bli\u0142em takie co\u015b (fragment kodu aplikacji GUI):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nprivate async Task SyncAcynsWebProcessing(CancellationToken token, int seconds2Run = 60, int threadCount = 50)\n{\n\tStopwatch watch = new Stopwatch(), global_watch = new Stopwatch();\n\tint run_times = 0;\n\tstring url = txtDebug.Text.Trim().Split(new&#x5B;] { '\\r', '\\n' }).FirstOrDefault();\n\tglobal_watch.Start();\n\n\twhile (true)\n\t{\n\t\tif (!token.IsCancellationRequested &amp;&amp;\n\t\t\tglobal_watch.ElapsedMilliseconds &gt; (seconds2Run * 1000))\/\/do this procedure X number of seconds\n\t\t\tbreak;\n\n\t\tvar all_tasks = new Task&lt;int&gt;&#x5B;threadCount];\n\t\twatch.Reset();\n\t\twatch.Start();\n\t\tfor (int i = 0; i &lt; threadCount; i++)\/\/create-and-run x tasks\n\t\t{\n\t\t\tall_tasks&#x5B;i] = Task.Run(async () =&gt;\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tusing (var client = new HttpClient())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar stackContent = await client.GetAsync(url, token);\n\t\t\t\t\t\tvar response = await stackContent.Content.ReadAsStringAsync();\n\t\t\t\t\t\tif (response.Length &gt; 10)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn response.Length;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (int.TryParse(response, out int j))\n\t\t\t\t\t\t\t\treturn j;\n\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (Exception ex)\n\t\t\t\t{\n\t\t\t\t\tthis.Dispatcher.Invoke(() =&gt;\/\/run something on UI thread\n\t\t\t\t\t{\n\t\t\t\t\t\ttxtDebug.AppendText(ex.ToString());\n\t\t\t\t\t});\n\t\t\t\t\treturn -2;\n\t\t\t\t}\n\t\t\t}, token);\n\t\t}\n\t\t\/\/wait for all threads to complete\n\t\tawait Task.WhenAll(all_tasks).ContinueWith((all_results) =&gt;\n\t\t{\n\t\t\twatch.Stop();\n\t\t\tthis.Dispatcher.Invoke(() =&gt;\/\/run something on UI thread\n\t\t\t{\n\t\t\t\tstring comm = &quot;&quot;;\n\t\t\t\ttxtDebug.AppendText(Environment.NewLine);\n\t\t\t\tforeach (var res in all_results.Result)\n\t\t\t\t{\n\t\t\t\t\ttxtDebug.AppendText(comm + res);\n\t\t\t\t\tcomm = &quot;,&quot;;\n\t\t\t\t}\n\t\t\t\ttxtDebug.AppendText($&quot;{Environment.NewLine}ElapsedMilliseconds: {watch.ElapsedMilliseconds}&quot;);\n\t\t\t});\n\n\t\t\twatch.Reset();\n\t\t\tforeach (Task&lt;int&gt; tsk in all_tasks) tsk.Dispose();\n\t\t\tall_tasks = null;\n\t\t}, token);\n\t\t\/\/await Task.Delay(250).ConfigureAwait(false);\n\t\trun_times++;\n\t}\n\n\tthis.Dispatcher.Invoke(() =&gt;\/\/run something on UI thread\n\t{\n\t\ttxtDebug.AppendText($&quot;{Environment.NewLine}----------{Environment.NewLine}Bottom line summary: {global_watch.ElapsedMilliseconds}&quot;\n\t\t\t+ $&quot; run {run_times} times&quot;);\n\t});\n}\n<\/pre><\/pre>\n\n\n\n<p>To cudo wykonuje przez zadan\u0105 ilo\u015b\u0107 sekund (domy\u015blnie 60) dzia\u0142anie polegaj\u0105ce na zasypywaniem serwera wielu kr\u00f3ciutkich zapyta\u0144 i sumuje odpowiedzi (kt\u00f3re s\u0105 ilo\u015bci\u0105 sum\u0105 w\u0105tk\u00f3w robocznych .NET). Robione jest to specjalnie przez X sekund i z zadan\u0105 ilo\u015bci\u0105 w\u0105tk\u00f3w (domy\u015blnie 50) aby r\u00f3wno obci\u0105\u017cy\u0107 (czyt. dobi\u0107) serwer.<\/p>\n\n\n\n<p>Wyniki, dla metody u\u017cywaj\u0105cej synchronicznych wywo\u0142a\u0144 (metoda http:\/\/localhost:4553\/sleep):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nhttp:\/\/localhost:4553\/sleep\n26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26\nElapsed millis: 9053\n26,26,26,26,27,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27\nElapsed millis: 7169\n29,29,29,29,29,29,29,30,29,29,30,30,30,30,31,30,30,30,30,36,30,31,36,31,35,35,35,31,35,31,36,31,36,35,36,36,36,36,36,36,36,36,36,35,36,36,36,36,35,36\nElapsed millis: 5199\n37,37,37,37,37,37,37,37,37,37,37,37,38,37,38,38,38,38,38,38,38,38,38,38,39,38,38,39,38,39,39,39,39,39,39,39,39,39,39,39,38,39,39,39,39,39,39,39,39,39\nElapsed millis: 4105\n39,39,39,39,39,39,39,39,39,39,40,39,39,40,40,39,40,40,39,39,40,40,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,40,41\nElapsed millis: 3706\n42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,43,42,42,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,42,43,43,43,43,43,43,43,43,43,43\nElapsed millis: 3126\n64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64\nElapsed millis: 2128\n65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65\nElapsed millis: 2073\n66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66\nElapsed millis: 2082\n67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67\nElapsed millis: 2066\n67,67,67,67,67,67,67,67,67,67,67,64,67,67,67,67,67,67,67,67,64,67,67,67,64,64,67,64,67,64,64,67,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64\nElapsed millis: 2098\n64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64\nElapsed millis: 2066\n64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64\nElapsed millis: 2122\n69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,68,69,69,69\nElapsed millis: 2059\n70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,69,70,70\nElapsed millis: 1798\n71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71\nElapsed millis: 1136\n71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,70,70,71,71\nElapsed millis: 1169\n71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,70,71,71,71,71,71,71\nElapsed millis: 2113\n71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,70,71,71,71,71,71,71,71,71,71,71,71,71,71\nElapsed millis: 2108\n71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,70,71,71,71,71,71,71,71,71,71,71,71,71\nElapsed millis: 2063\n75,75,75,75,75,75,75,71,71,71,71,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,74,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75\nElapsed millis: 2056\n----------\n<\/pre><\/pre>\n\n\n\n<p><span style=\"color: #ff9900;\"><strong> Took 61565 millis to run 21 times<\/strong><\/span><\/p>\n\n\n\n<p>A teraz to samo dla metody wykorzysuj\u0105ce asyncrhoniczne wyow\u0142ania (async\/await http:\/\/localhost:4553\/delay):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nhttp:\/\/localhost:4553\/delay\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1150\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1075\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1058\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1059\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1095\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1049\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1082\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1073\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1070\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1076\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1062\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1080\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1059\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1081\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1074\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1075\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1066\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1087\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1062\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1091\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1070\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1073\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1079\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1070\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1060\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1085\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1063\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1095\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1063\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1107\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1077\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1087\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1076\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1054\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1068\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1085\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1075\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1079\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1068\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1089\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1074\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1064\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1062\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1061\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1059\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1078\n44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44\nElapsed millis: 1066\n44,45,45,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,44,44,45,44,44,45,44,44,45,44,44,44,44,44,44,44\nElapsed millis: 1070\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1061\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1069\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1094\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1067\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1043\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1094\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1069\n45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45\nElapsed millis: 1077\n----------\n<\/pre><\/pre>\n\n\n\n<p><strong><span style=\"color: #ff9900;\">Took 60225 millis to run 56 times<\/span><\/strong><\/p>\n\n\n\n<p>Jak wida\u0107 dla takiego samego czasu dzia\u0142ania (oko\u0142o 60 sekund) ilo\u015b\u0107 obs\u0142u\u017conych zada\u0144 jest przesz\u0142o dwa razy wi\u0119ksza &#8211; 2x przyspieszenie. <span style=\"color: #ff9900;\">21 <\/span>vs <span style=\"color: #ff9900;\">56<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>No dobra, po epokowej przerwie (ostatnio wpis jakie\u015b 4 lata temu?!!) mam co\u015b ciekawego. Szybki up-to-date, wkr\u0119ci\u0142em si\u0119 w nowego &#8222;dotneta&#8221; (.NET core) a \u015bci\u015blej ASP.NET Core. Jak zwykle przegl\u0105daj\u0105c czelu\u015bcie internetu trafi\u0142em tutaj:&nbsp;https:\/\/caleblloyd.com\/software\/net-core-mvc-thread-pool-vs-async\/ Wiedzia\u0142em \u017ce s\u0142owo kluczowe async, await &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/haos.hopto.org\/blog\/2017\/07\/26\/kodowanie-asynchroniczne-w-csharp-na-webie\/\">Czytaj wi\u0119cej &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79,4,1,5],"tags":[80,81],"class_list":["post-730","post","type-post","status-publish","format-standard","hentry","category-c","category-developer","category-uncategorized","category-tech","tag-async","tag-dev"],"_links":{"self":[{"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/comments?post=730"}],"version-history":[{"count":24,"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/posts\/730\/revisions"}],"predecessor-version":[{"id":929,"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/posts\/730\/revisions\/929"}],"wp:attachment":[{"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/media?parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/categories?post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haos.hopto.org\/blog\/wp-json\/wp\/v2\/tags?post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}