예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        private BulletClient CreateNewClient(int index)
        {
            var result = new BulletClient(_url, index);

            return(result);
        }