diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkOperationType.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkOperationType.cs
new file mode 100644
index 0000000000..b18fb1c318
--- /dev/null
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkOperationType.cs
@@ -0,0 +1,16 @@
+//------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//------------------------------------------------------------
+
+namespace CosmosBenchmark
+{
+ ///
+ /// Benchmark operation type.
+ ///
+ public enum BenchmarkOperationType
+ {
+ Read,
+ Insert,
+ Query
+ }
+}
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/CosmosDiagnosticsLogger.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/CosmosDiagnosticsLogger.cs
index 9a399c5dc8..e08b2dd6da 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/CosmosDiagnosticsLogger.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/CosmosDiagnosticsLogger.cs
@@ -6,11 +6,8 @@ namespace CosmosBenchmark
{
using System;
using System.Collections.Concurrent;
- using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
using Microsoft.Azure.Cosmos;
using Newtonsoft.Json.Linq;
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/IBenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/IBenchmarkOperation.cs
index d6933fcce5..3580a8a6fc 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/IBenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/IBenchmarkOperation.cs
@@ -6,10 +6,26 @@ namespace CosmosBenchmark
{
using System.Threading.Tasks;
+ ///
+ /// Represents the Benchmark operation.
+ ///
internal interface IBenchmarkOperation
{
- Task PrepareAsync();
+ ///
+ /// Benchmark operation type.
+ ///
+ BenchmarkOperationType OperationType { get; }
+ ///
+ /// Executes Benchmark operation once asynchronously.
+ ///
+ /// The operation result wrapped by task.
Task ExecuteOnceAsync();
+
+ ///
+ /// Prepares Benchmark operation asynchronously.
+ ///
+ /// The task related to method's work.
+ Task PrepareAsync();
}
}
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/InsertV2BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/InsertV2BenchmarkOperation.cs
index 744bb9f577..124c841085 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/InsertV2BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/InsertV2BenchmarkOperation.cs
@@ -38,6 +38,8 @@ public InsertV2BenchmarkOperation(
this.sampleJObject = JsonHelper.Deserialize>(sampleJson);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Insert;
+
public async Task ExecuteOnceAsync()
{
ResourceResponse itemResponse = await this.documentClient.CreateDocumentAsync(
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryStreamSinglePkV2BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryStreamSinglePkV2BenchmarkOperation.cs
index 1bf3bf245e..b0f071f6de 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryStreamSinglePkV2BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryStreamSinglePkV2BenchmarkOperation.cs
@@ -47,6 +47,8 @@ public QueryStreamSinglePkV2BenchmarkOperation(
this.containerUri = UriFactory.CreateDocumentCollectionUri(this.databsaeName, this.containerName);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Query;
+
public async Task ExecuteOnceAsync()
{
IDocumentQuery query = this.documentClient.CreateDocumentQuery(
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryTSinglePkV2BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryTSinglePkV2BenchmarkOperation.cs
index 7d58447859..cd50a789b8 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryTSinglePkV2BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/QueryTSinglePkV2BenchmarkOperation.cs
@@ -46,6 +46,8 @@ public QueryTSinglePkV2BenchmarkOperation(
this.sampleJObject[this.partitionKeyPath] = this.executionItemPartitionKey;
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Query;
+
public async Task ExecuteOnceAsync()
{
IDocumentQuery> query = this.documentClient.CreateDocumentQuery>(
@@ -107,7 +109,7 @@ public async Task PrepareAsync()
new RequestOptions() { PartitionKey = new PartitionKey(this.executionItemPartitionKey) });
if (itemResponse.StatusCode != HttpStatusCode.Created)
{
- throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}");
+ throw new Exception($"Create failed with status code: {itemResponse.StatusCode}");
}
this.initialized = true;
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadFeedStreamV2BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadFeedStreamV2BenchmarkOperation.cs
index 379cd363e6..0a9b9e3d7f 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadFeedStreamV2BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadFeedStreamV2BenchmarkOperation.cs
@@ -40,6 +40,8 @@ public ReadFeedStreamV2BenchmarkOperation(
this.sampleJObject = JsonHelper.Deserialize>(sampleJson);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public async Task ExecuteOnceAsync()
{
Uri containerUri = UriFactory.CreateDocumentCollectionUri(this.databsaeName, this.containerName);
@@ -75,7 +77,7 @@ public async Task PrepareAsync()
new RequestOptions() { PartitionKey = new PartitionKey(this.nextExecutionItemPartitionKey) });
if (itemResponse.StatusCode != HttpStatusCode.Created)
{
- throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}");
+ throw new Exception($"Create failed with status code: {itemResponse.StatusCode}");
}
}
}
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadNotExistsV2BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadNotExistsV2BenchmarkOperation.cs
index f5e8f94c68..1d8b99449e 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadNotExistsV2BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadNotExistsV2BenchmarkOperation.cs
@@ -22,6 +22,8 @@ internal class ReadNotExistsV2BenchmarkOperation : IBenchmarkOperation
private readonly DocumentClient documentClient;
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public ReadNotExistsV2BenchmarkOperation(
DocumentClient documentClient,
string dbName,
@@ -52,7 +54,7 @@ public async Task ExecuteOnceAsync()
{
if (dce.StatusCode != HttpStatusCode.NotFound)
{
- throw new Exception($"ReadItem failed wth {dce?.StatusCode} {dce?.ToString()}");
+ throw new Exception($"ReadItem failed with {dce?.StatusCode} {dce?.ToString()}");
}
return new OperationResult()
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadStreamExistsV2BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadStreamExistsV2BenchmarkOperation.cs
index 7afd4cdf71..c7419db811 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadStreamExistsV2BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadStreamExistsV2BenchmarkOperation.cs
@@ -25,6 +25,8 @@ internal class ReadStreamExistsV2BenchmarkOperation : IBenchmarkOperation
private readonly DocumentClient documentClient;
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public ReadStreamExistsV2BenchmarkOperation(
DocumentClient documentClient,
string dbName,
@@ -84,7 +86,7 @@ public async Task PrepareAsync()
if (itemResponse.StatusCode != HttpStatusCode.Created)
{
- throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}");
+ throw new Exception($"Create failed with status code: {itemResponse.StatusCode}");
}
}
}
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadTExistsV2BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadTExistsV2BenchmarkOperation.cs
index 061183c575..7e161f8ffc 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadTExistsV2BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v2/ReadTExistsV2BenchmarkOperation.cs
@@ -26,6 +26,8 @@ internal class ReadTExistsV2BenchmarkOperation : IBenchmarkOperation
private readonly DocumentClient documentClient;
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public ReadTExistsV2BenchmarkOperation(
DocumentClient documentClient,
string dbName,
@@ -85,7 +87,7 @@ public async Task PrepareAsync()
if (itemResponse.StatusCode != HttpStatusCode.Created)
{
- throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}");
+ throw new Exception($"Create failed with status code: {itemResponse.StatusCode}");
}
}
}
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/InsertV3BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/InsertV3BenchmarkOperation.cs
index 1ab5861242..504148bfda 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/InsertV3BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/InsertV3BenchmarkOperation.cs
@@ -37,6 +37,8 @@ public InsertV3BenchmarkOperation(
this.sampleJObject = JsonHelper.Deserialize>(sampleJson);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Insert;
+
public async Task ExecuteOnceAsync()
{
using (MemoryStream input = JsonHelper.ToStream(this.sampleJObject))
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/QueryTV3BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/QueryTV3BenchmarkOperation.cs
index bdb0b38cf8..f78153034b 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/QueryTV3BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/QueryTV3BenchmarkOperation.cs
@@ -31,6 +31,8 @@ internal abstract class QueryTV3BenchmarkOperation : IBenchmarkOperation
public abstract bool IsPaginationEnabled { get; }
public abstract bool IsQueryStream { get; }
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Query;
+
protected string executionItemId = null;
protected string executionPartitionKey = null;
@@ -291,7 +293,7 @@ public virtual async Task PrepareAsync()
if (itemResponse.StatusCode != HttpStatusCode.Created)
{
- throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}");
+ throw new Exception($"Create failed with status code: {itemResponse.StatusCode}");
}
}
}
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadFeedStreamV3BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadFeedStreamV3BenchmarkOperation.cs
index 99789040b0..3b9c5cd800 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadFeedStreamV3BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadFeedStreamV3BenchmarkOperation.cs
@@ -39,6 +39,8 @@ public ReadFeedStreamV3BenchmarkOperation(
this.sampleJObject = JsonHelper.Deserialize>(sampleJson);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public async Task ExecuteOnceAsync()
{
FeedIterator feedIterator = this.container
@@ -50,7 +52,7 @@ public async Task ExecuteOnceAsync()
ResponseMessage feedResponse = await feedIterator.ReadNextAsync();
if (feedResponse.StatusCode != HttpStatusCode.OK)
{
- throw new Exception($"ReadItem failed wth {feedResponse.StatusCode}");
+ throw new Exception($"ReadItem failed with {feedResponse.StatusCode}");
}
return new OperationResult()
@@ -84,7 +86,7 @@ public async Task PrepareAsync()
if (itemResponse.StatusCode != HttpStatusCode.Created)
{
- throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}");
+ throw new Exception($"Create failed with status code: {itemResponse.StatusCode}");
}
}
}
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadNotExistsV3BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadNotExistsV3BenchmarkOperation.cs
index c97d1af4b7..1804ea9852 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadNotExistsV3BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadNotExistsV3BenchmarkOperation.cs
@@ -32,6 +32,8 @@ public ReadNotExistsV3BenchmarkOperation(
this.container = cosmosClient.GetContainer(this.databsaeName, this.containerName);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public async Task ExecuteOnceAsync()
{
using (ResponseMessage itemResponse = await this.container.ReadItemStreamAsync(
@@ -40,7 +42,7 @@ public async Task ExecuteOnceAsync()
{
if (itemResponse.StatusCode != HttpStatusCode.NotFound)
{
- throw new Exception($"ReadItem failed wth {itemResponse.StatusCode}");
+ throw new Exception($"ReadItem failed with {itemResponse.StatusCode}");
}
return new OperationResult()
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsV3BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsV3BenchmarkOperation.cs
index aba0a4ea7a..fabe8f20bd 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsV3BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsV3BenchmarkOperation.cs
@@ -39,6 +39,8 @@ public ReadStreamExistsV3BenchmarkOperation(
this.sampleJObject = JsonHelper.Deserialize>(sampleJson);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public async Task ExecuteOnceAsync()
{
using (ResponseMessage itemResponse = await this.container.ReadItemStreamAsync(
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsWithDiagnosticsV3BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsWithDiagnosticsV3BenchmarkOperation.cs
index ebdc14924b..74f2ac67f7 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsWithDiagnosticsV3BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsWithDiagnosticsV3BenchmarkOperation.cs
@@ -39,6 +39,8 @@ public ReadStreamExistsWithDiagnosticsV3BenchmarkOperation(
this.sampleJObject = JsonHelper.Deserialize>(sampleJson);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public async Task ExecuteOnceAsync()
{
using (ResponseMessage itemResponse = await this.container.ReadItemStreamAsync(
@@ -47,7 +49,7 @@ public async Task ExecuteOnceAsync()
{
if (itemResponse.StatusCode != HttpStatusCode.OK)
{
- throw new Exception($"ReadItem failed wth {itemResponse.StatusCode}");
+ throw new Exception($"ReadItem failed with {itemResponse.StatusCode}");
}
string diagnostics = itemResponse.Diagnostics.ToString();
diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadTExistsV3BenchmarkOperation.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadTExistsV3BenchmarkOperation.cs
index 7fd40397be..bb6295356e 100644
--- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadTExistsV3BenchmarkOperation.cs
+++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/v3/ReadTExistsV3BenchmarkOperation.cs
@@ -10,7 +10,6 @@ namespace CosmosBenchmark
using System.Net;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos;
- using Newtonsoft.Json.Linq;
internal class ReadTExistsV3BenchmarkOperation : IBenchmarkOperation
{
@@ -40,6 +39,8 @@ public ReadTExistsV3BenchmarkOperation(
this.sampleJObject = JsonHelper.Deserialize>(sampleJson);
}
+ public BenchmarkOperationType OperationType => BenchmarkOperationType.Read;
+
public async Task ExecuteOnceAsync()
{
ItemResponse> itemResponse = await this.container.ReadItemAsync>(
@@ -47,7 +48,7 @@ public async Task ExecuteOnceAsync()
new PartitionKey(this.nextExecutionItemPartitionKey));
if (itemResponse.StatusCode != HttpStatusCode.OK)
{
- throw new Exception($"ReadItem failed wth {itemResponse.StatusCode}");
+ throw new Exception($"ReadItem failed with {itemResponse.StatusCode}");
}
return new OperationResult()
@@ -81,7 +82,7 @@ public async Task PrepareAsync()
if (itemResponse.StatusCode != HttpStatusCode.Created)
{
- throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}");
+ throw new Exception($"Create failed with status code: {itemResponse.StatusCode}");
}
}
}