Last active
March 2, 2023 10:17
-
-
Save skurik/f3461c0670a2b4dad3f457b8676d8b1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Program"> | |
<Namespace>System.Net.Http</Namespace> | |
<Namespace>Newtonsoft.Json</Namespace> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Query> | |
void Main() | |
{ | |
} | |
public Task RunOnContainerApp() => Run("https://mews-develop-appservice-poc5-weu.lemonmushroom-5960d771.westeurope.azurecontainerapps.io"); | |
public Task RunOnLinuxContainerAppService() => Run("https://mews-develop-appservice-poc3-weu.azurewebsites.net"); | |
public Task RunOnWindowsAppService() => Run("https://mews-develop-appservice-poc2-weu.azurewebsites.net"); | |
public async Task Run(string host) | |
{ | |
using (var client = new HttpClient()) | |
{ | |
var rnd = new Random(); | |
var tasks = Enumerable.Range(0, 2).Select(_ => Task.Run(() => Run(client, rnd, host))).ToList(); | |
await System.Threading.Tasks.Task.WhenAll(tasks); | |
} | |
} | |
public async Task Run(HttpClient client, Random rnd, string host) | |
{ | |
foreach (var i in Enumerable.Range(0, 3)) | |
{ | |
using var request = new HttpRequestMessage(HttpMethod.Get, $"{host}/api/benchmark/hash?loops=100000"); | |
try | |
{ | |
var response = await client.SendAsync(request); | |
if (!response.IsSuccessStatusCode) | |
{ | |
(await response.Content.ReadAsStringAsync()).Dump(response.StatusCode.ToString()); | |
} | |
} | |
catch (Exception e) | |
{ | |
e.Dump(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment