using System; using System.Collections.Generic; using System.Net.Http; using System.Threading; using System.Threading.Tasks; using System.Text; using System.Text.Json; using AsbCloudApp.Data; namespace AsbCloudDevOperations { public class ControllerLoadTester { private readonly HttpClient client = new(); public void TestControllerRoute(string route, CancellationToken token = default) { var host = "http://localhost:5000"; var json = JsonSerializer.Serialize(new List()); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); Console.WriteLine("Start"); var tasks = new Task[100]; for (var i = 0; i < 100; i++) { var res = client.PostAsync(new Uri($"{host}/{route}{i}"), stringContent, token); tasks[i] = res; }; Task.WaitAll(tasks, token); Console.WriteLine("End"); } } }