private void SetupClients(int connections) { _totalRequests = 0; _failedRequests = 0; Clients = new BulletClient[connections]; for (int i = 0; i < connections; i++) { var client = CreateNewClient(i + 1); Clients[i] = client; } }
private Task StartGetClient(BulletClient client, TimeSpan duration, Stopwatch stopwatch, CancellationToken token = default) { try { var ctk = token; while (!ctk.IsCancellationRequested && duration.TotalMilliseconds > stopwatch.Elapsed.TotalMilliseconds) { client.Get(); Interlocked.Increment(ref _totalRequests); } } catch (Exception) { Interlocked.Increment(ref _failedRequests); } finally { } return(Task.CompletedTask); }
private BulletClient CreateNewClient(int index) { var result = new BulletClient(_url, index); return(result); }