/// <summary> /// Main method for the sample. /// </summary> /// <param name="args">command line arguments.</param> public static async Task Main(string[] args) { try { BenchmarkConfig config = BenchmarkConfig.From(args); ThreadPool.SetMinThreads(config.MinThreadPoolSize, config.MinThreadPoolSize); TelemetrySpan.IncludePercentile = config.EnableLatencyPercentiles; string accountKey = config.Key; config.Key = null; // Don't print config.Print(); Program program = new Program(); await program.ExecuteAsync(config, accountKey); if (TelemetrySpan.IncludePercentile) { TelemetrySpan.LatencyHistogram.OutputPercentileDistribution(Console.Out); using (StreamWriter fileWriter = new StreamWriter("HistogramResults.hgrm")) { TelemetrySpan.LatencyHistogram.OutputPercentileDistribution(fileWriter); } } } finally { Console.WriteLine($"{nameof(CosmosBenchmark)} completed successfully."); if (Debugger.IsAttached) { Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } } }
/// <summary> /// Main method for the sample. /// </summary> /// <param name="args">command line arguments.</param> public static async Task Main(string[] args) { try { BenchmarkConfig config = BenchmarkConfig.From(args); await Program.AddAzureInfoToRunSummary(); ThreadPool.SetMinThreads(config.MinThreadPoolSize, config.MinThreadPoolSize); if (config.EnableLatencyPercentiles) { TelemetrySpan.IncludePercentile = true; TelemetrySpan.ResetLatencyHistogram(config.ItemCount); } config.Print(); Program program = new Program(); RunSummary runSummary = await program.ExecuteAsync(config); } finally { Console.WriteLine($"{nameof(CosmosBenchmark)} completed successfully."); if (Debugger.IsAttached) { Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } } }
/// <summary> /// Main method for the sample. /// </summary> /// <param name="args">command line arguments.</param> public static async Task Main(string[] args) { BenchmarkConfig config = BenchmarkConfig.From(args); ThreadPool.SetMinThreads(config.MinThreadPoolSize, config.MinThreadPoolSize); string accountKey = config.Key; config.Key = null; // Don't print config.Print(); CosmosClientOptions clientOptions = new CosmosClientOptions() { ApplicationName = "cosmosdbdotnetbenchmark", RequestTimeout = new TimeSpan(1, 0, 0), MaxRetryAttemptsOnRateLimitedRequests = 0, MaxRetryWaitTimeOnRateLimitedRequests = TimeSpan.FromSeconds(60), MaxRequestsPerTcpConnection = 2, }; using (CosmosClient client = new CosmosClient( config.EndPoint, accountKey, clientOptions)) { Program program = new Program(client); await program.ExecuteAsync(config); } TelemetrySpan.LatencyHistogram.OutputPercentileDistribution(Console.Out); using (StreamWriter fileWriter = new StreamWriter("HistogramResults.hgrm")) { TelemetrySpan.LatencyHistogram.OutputPercentileDistribution(fileWriter); } Console.WriteLine($"{nameof(CosmosBenchmark)} completed successfully."); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); }