private async Task SetupAllAsync() { using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(_timeSeconds))) { PerfScenarioConfig c = new PerfScenarioConfig() { Id = 0, SizeBytes = _messageSizeBytes, Writer = _log, AuthType = _authType, Transport = _transportType, PoolSize = _poolSize }; for (int i = 0; i < _tests.Length; i++) { c.Id = i; _tests[i] = _scenarioFactory(c); } ulong statTotalCompleted = 0; ulong statTotalFaulted = 0; ulong statTotalCancelled = 0; double statTotalSeconds = 0.0; List <double> statRps = new List <double>(); var runner = new ParallelRun( _tests, _parallelOperations, (test) => test.SetupAsync(CancellationToken.None), (statInterimCompleted, statInterimFaulted, statInterimCancelled, statInterimTimeSec) => { statTotalCompleted += statInterimCompleted; statTotalFaulted += statInterimFaulted; statTotalCancelled += statInterimCancelled; statTotalSeconds += statInterimTimeSec; // Interim: double requestsPerSec = statInterimCompleted / statInterimTimeSec; statRps.Add(requestsPerSec); // Totals: double totalRequestsPerSec = statTotalCompleted / statTotalSeconds; (double avgRps, double stdDevRps) = CalculateAvgAndStDev(statRps); SystemMetrics.GetMetrics(out int cpuPercent, out long memoryBytes, out long gcBytes, out long tcpConn, out long devConn); Console.WriteLine($"[{_sw.Elapsed}] Setup Statistics:"); Console.WriteLine($"RPS : {requestsPerSec,10:N2} R/s Avg: {avgRps,10:N2} R/s +/-StdDev: {stdDevRps,10:N2} R/s"); Console.WriteLine($"Connected : {devConn,10:N0} "); Console.WriteLine($"CPU : {cpuPercent,10:N2}% Mem: {GetHumanReadableBytes(memoryBytes)} GC_Mem: {GetHumanReadableBytes(gcBytes)} TCP: {tcpConn,4:N0}"); Console.WriteLine("----"); Console.WriteLine($"TOTALs: "); Console.WriteLine($"Requests : Completed: {statTotalCompleted,10:N0} Faulted: {statTotalFaulted,10:N0} Cancelled: {statTotalCancelled,10:N0}"); }); await runner.RunAsync(runOnce : true, ct : cts.Token).ConfigureAwait(false); } }
public DeviceOneD2CTest(PerfScenarioConfig config) : base(config) { _m.Id = _id; _messageBytes = new byte[_sizeBytes]; BitConverter.TryWriteBytes(_messageBytes, _id); }
public ServiceClientScenario(PerfScenarioConfig config) : base(config) { _m.Id = _id; _mMethod.Id = _id; _messageBytes = new byte[_sizeBytes]; BitConverter.TryWriteBytes(_messageBytes, _id); }
protected PerfScenario(PerfScenarioConfig config) { _writer = config.Writer; _sizeBytes = config.SizeBytes; _authType = config.AuthType; _transport = config.Transport; _id = config.Id; }
public ServiceClientScenario(PerfScenarioConfig config) : base(config) { _m.Id = _id; _mMethod.Id = _id; _messageBytes = new byte[_sizeBytes]; byte[] idBytes = BitConverter.GetBytes(_id); Buffer.BlockCopy(idBytes, 0, _messageBytes, 0, idBytes.Length); _methodPayload = "{\"Data\":\"" + Convert.ToBase64String(_messageBytes) + "\"}"; }
public DeviceClientScenario(PerfScenarioConfig config) : base(config) { _m.Id = _id; _mRecv.Id = _id; _mRecv.OperationType = TelemetryMetrics.DeviceOperationReceive; _mMethod.Id = _id; _messageBytes = new byte[_sizeBytes]; _pooled = config.PoolSize > 0; if (_pooled) { _poolSize = config.PoolSize; } BitConverter.TryWriteBytes(_messageBytes, _id); }
public ServiceC2DTest(PerfScenarioConfig config) : base(config) { CreateServiceClient(); }
public DeviceAllNoRetry(PerfScenarioConfig config) : base(config) { }
public DeviceMethodsNoRetry(PerfScenarioConfig config) : base(config) { }
public DeviceAllTest(PerfScenarioConfig config) : base(config) { }
public HarnessBaseline(PerfScenarioConfig config) : base(config) { _m.Id = _id; _messageBytes = new byte[_sizeBytes]; BitConverter.TryWriteBytes(_messageBytes, _id); }
public GenerateIotHubConfigTest(PerfScenarioConfig config) : base(config) { }
public DeviceMethodTest(PerfScenarioConfig config) : base(config) { }
public DeviceAllOpenCloseTest(PerfScenarioConfig config) : base(config) { }