Skip to content

Commit 2d3c110

Browse files
author
jaguzman
committed
Added benchmarks for the azure storage table service
1 parent 4e7d6ae commit 2d3c110

12 files changed

+56
-21
lines changed

benchmarks/DotNetToolkit.Repository.Performance/App.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<connectionStrings>
44
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=tempdb;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
55
<add name="AzureStorageBlobConnection" connectionString="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;" />
6+
<add name="AzureStorageTableConnection" connectionString="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;" />
67
</connectionStrings>
78
</configuration>

benchmarks/DotNetToolkit.Repository.Performance/BenchmarkBase.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using AdoNet;
44
using AzureStorageBlob;
5+
using AzureStorageTable;
56
using BenchmarkDotNet.Attributes;
67
using Configuration.Options;
78
using Data;
@@ -106,6 +107,14 @@ protected IRepositoryOptions BuildOptions(ContextProviderType provider)
106107
createIfNotExists: true);
107108
break;
108109
}
110+
case ContextProviderType.AzureStorageTable:
111+
{
112+
builder.UseAzureStorageTable(
113+
nameOrConnectionString: "AzureStorageTableConnection",
114+
tableName: "TableName" + Guid.NewGuid().ToString("N").ToUpper(),
115+
createIfNotExists: true);
116+
break;
117+
}
109118
default:
110119
throw new ArgumentOutOfRangeException(nameof(provider));
111120
}
@@ -125,6 +134,7 @@ public virtual IEnumerable<ContextProviderType> Providers()
125134
ContextProviderType.EntityFramework,
126135
ContextProviderType.EntityFrameworkCore,
127136
ContextProviderType.AzureStorageBlob,
137+
ContextProviderType.AzureStorageTable,
128138
};
129139
}
130140

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Add.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Setup()
1414
{
1515
BaseSetup();
1616

17-
_customer = new Customer { Name = "Random Name" };
17+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
1818

1919
_repo = new Repository<Customer>(BuildOptions(Provider));
2020
}

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Delete.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Setup()
1414
{
1515
BaseSetup();
1616

17-
_customer = new Customer { Name = "Random Name" };
17+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
1818

1919
_repo = new Repository<Customer>(BuildOptions(Provider));
2020
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Find.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Setup()
2222

2323
_pagingOptions = _defaultOptions.Page(1, 10);
2424

25-
_customer = new Customer { Name = "Random Name" };
25+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

2727
_repo = new Repository<Customer>(BuildOptions(Provider));
2828
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.GroupBy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Setup()
2222

2323
_pagingOptions = _defaultOptions.Page(1, 10);
2424

25-
_customer = new Customer { Name = "Random Name" };
25+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

2727
_repo = new Repository<Customer>(BuildOptions(Provider));
2828
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.ToDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Setup()
2222

2323
_pagingOptions = _defaultOptions.Page(1, 10);
2424

25-
_customer = new Customer { Name = "Random Name" };
25+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

2727
_repo = new Repository<Customer>(BuildOptions(Provider));
2828
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Update.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Setup()
1414
{
1515
BaseSetup();
1616

17-
_customer = new Customer { Name = "Random Name" };
17+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
1818

1919
_repo = new Repository<Customer>(BuildOptions(Provider));
2020
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Data/ContextProviderType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public enum ContextProviderType
1010
EntityFramework,
1111
EntityFrameworkCore,
1212
AzureStorageBlob,
13+
AzureStorageTable,
1314
}
1415
}
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
namespace DotNetToolkit.Repository.Performance.Data
22
{
3+
using System;
34
using System.ComponentModel.DataAnnotations;
5+
using System.ComponentModel.DataAnnotations.Schema;
46

5-
public class Customer
7+
public class Customer : Microsoft.WindowsAzure.Storage.Table.TableEntity
68
{
7-
public int Id { get; set; }
8-
[Required]
9+
private int _id;
10+
11+
[Key]
12+
[DatabaseGenerated(DatabaseGeneratedOption.None)]
13+
public int Id
14+
{
15+
get { return _id; }
16+
set
17+
{
18+
_id = value;
19+
RowKey = _id.ToString();
20+
}
21+
}
922
public string Name { get; set; }
23+
24+
// for azure table compability (do not map since they are not realted to sql tests)
25+
[NotMapped]
26+
public new DateTimeOffset Timestamp { get; set; }
27+
[NotMapped]
28+
public new string ETag { get; set; }
29+
30+
public Customer()
31+
{
32+
PartitionKey = string.Empty;
33+
}
1034
}
1135
}

0 commit comments

Comments
 (0)