/// <summary> /// Run samples for Order By queries. /// </summary> /// <returns>a Task object.</returns> private async Task ExecuteAsync(BenchmarkConfig config) { if (config.CleanupOnStart) { Database database = this.client.GetDatabase(config.Database); await database.DeleteStreamAsync(); } ContainerResponse containerResponse = await this.CreatePartitionedContainerAsync(config); Container container = containerResponse; int?currentContainerThroughput = await container.ReadThroughputAsync(); Console.WriteLine($"Using container {config.Container} with {currentContainerThroughput} RU/s"); int taskCount = config.GetTaskCount(currentContainerThroughput.Value); Console.WriteLine("Starting Inserts with {0} tasks", taskCount); Console.WriteLine(); string partitionKeyPath = containerResponse.Resource.PartitionKeyPath; int numberOfItemsToInsert = config.ItemCount / taskCount; string sampleItem = File.ReadAllText(config.ItemTemplateFile); IBenchmarkOperatrion benchmarkOperation = null; switch (config.WorkloadType.ToLower()) { case "insert": benchmarkOperation = new InsertBenchmarkOperation( container, partitionKeyPath, sampleItem); break; case "read": benchmarkOperation = new ReadBenchmarkOperation( container, partitionKeyPath, sampleItem); break; default: throw new NotImplementedException($"Unsupported workload type {config.WorkloadType}"); } IExecutionStrategy execution = IExecutionStrategy.StartNew(config, benchmarkOperation); await execution.ExecuteAsync(taskCount, numberOfItemsToInsert, 0.01); if (config.CleanupOnFinish) { Console.WriteLine($"Deleting Database {config.Database}"); Database database = this.client.GetDatabase(config.Database); await database.DeleteStreamAsync(); } }
public SerialOperationExecutor( string executorId, IBenchmarkOperatrion benchmarkOperation) { this.executorId = executorId; this.operation = benchmarkOperation; this.SuccessOperationCount = 0; this.FailedOperationCount = 0; }
public ParallelExecutionStrategy( IBenchmarkOperatrion benchmarkOperation) { this.benchmarkOperation = benchmarkOperation; }