Skip to content

Commit 4e7d6ae

Browse files
author
jaguzman
committed
Added benchmarks for the azure storage blob service
1 parent 4118540 commit 4e7d6ae

18 files changed

+229
-4
lines changed

benchmarks/DotNetToolkit.Repository.Performance/App.config

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

benchmarks/DotNetToolkit.Repository.Performance/BenchmarkBase.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace DotNetToolkit.Repository.Performance
22
{
33
using AdoNet;
4+
using AzureStorageBlob;
45
using BenchmarkDotNet.Attributes;
56
using Configuration.Options;
67
using Data;
@@ -97,6 +98,14 @@ protected IRepositoryOptions BuildOptions(ContextProviderType provider)
9798
builder.UseEntityFrameworkCore<EfCoreDbContext>(x => x.UseSqlServer(ConnectionString));
9899
break;
99100
}
101+
case ContextProviderType.AzureStorageBlob:
102+
{
103+
builder.UseAzureStorageBlob(
104+
nameOrConnectionString: "AzureStorageBlobConnection",
105+
container: Guid.NewGuid().ToString(),
106+
createIfNotExists: true);
107+
break;
108+
}
100109
default:
101110
throw new ArgumentOutOfRangeException(nameof(provider));
102111
}
@@ -114,7 +123,8 @@ public virtual IEnumerable<ContextProviderType> Providers()
114123
ContextProviderType.AdoNet,
115124
ContextProviderType.NHibernate,
116125
ContextProviderType.EntityFramework,
117-
ContextProviderType.EntityFrameworkCore
126+
ContextProviderType.EntityFrameworkCore,
127+
ContextProviderType.AzureStorageBlob,
118128
};
119129
}
120130

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ public enum ContextProviderType
99
NHibernate,
1010
EntityFramework,
1111
EntityFrameworkCore,
12+
AzureStorageBlob,
1213
}
1314
}

benchmarks/DotNetToolkit.Repository.Performance/DotNetToolkit.Repository.Performance.csproj

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
<ItemGroup>
3232
<ProjectReference Include="..\..\src\DotNetToolkit.Repository.AdoNet\DotNetToolkit.Repository.AdoNet.csproj" />
33+
<ProjectReference Include="..\..\src\DotNetToolkit.Repository.AzureStorageBlob\DotNetToolkit.Repository.AzureStorageBlob.csproj" />
3334
<ProjectReference Include="..\..\src\DotNetToolkit.Repository.EntityFrameworkCore\DotNetToolkit.Repository.EntityFrameworkCore.csproj" />
3435
<ProjectReference Include="..\..\src\DotNetToolkit.Repository.EntityFramework\DotNetToolkit.Repository.EntityFramework.csproj" />
3536
<ProjectReference Include="..\..\src\DotNetToolkit.Repository.InMemory\DotNetToolkit.Repository.InMemory.csproj" />
@@ -43,4 +44,40 @@
4344
<Reference Include="System.Configuration" />
4445
</ItemGroup>
4546

47+
<ItemGroup>
48+
<None Update="Tasks\tools\azure-storage-emulator\AzureStorageEmulator.exe">
49+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
50+
</None>
51+
<None Update="Tasks\tools\azure-storage-emulator\AzureStorageEmulator.exe.config">
52+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
53+
</None>
54+
<None Update="Tasks\tools\azure-storage-emulator\Microsoft.Azure.DevelopmentStorage.Services.dll">
55+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
56+
</None>
57+
<None Update="Tasks\tools\azure-storage-emulator\Microsoft.Azure.DevelopmentStorage.Store.dll">
58+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
59+
</None>
60+
<None Update="Tasks\tools\azure-storage-emulator\Microsoft.Azure.Storage.Emulator.Controller.dll">
61+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
62+
</None>
63+
<None Update="Tasks\tools\azure-storage-emulator\Microsoft.Data.Edm.dll">
64+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
65+
</None>
66+
<None Update="Tasks\tools\azure-storage-emulator\Microsoft.Data.OData.dll">
67+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
68+
</None>
69+
<None Update="Tasks\tools\azure-storage-emulator\Microsoft.Data.Services.Client.dll">
70+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
71+
</None>
72+
<None Update="Tasks\tools\azure-storage-emulator\Microsoft.Data.Services.dll">
73+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
74+
</None>
75+
<None Update="Tasks\tools\azure-storage-emulator\StartStorageEmulator.cmd">
76+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
77+
</None>
78+
<None Update="Tasks\tools\azure-storage-emulator\System.Spatial.dll">
79+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
80+
</None>
81+
</ItemGroup>
82+
4683
</Project>

benchmarks/DotNetToolkit.Repository.Performance/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ class Program
88
{
99
static void Main(string[] args)
1010
{
11-
Console.WriteLine("Using ConnectionString: " + BenchmarkBase.ConnectionString);
12-
11+
Console.WriteLine("// * Database Setup: Start *");
1312
EnsureDBSetup();
13+
Console.WriteLine("// * Database Setup: End *");
1414

15-
Console.WriteLine("Database setup complete.");
15+
Console.WriteLine("// * AzureStorageEmulator: Start *");
16+
Tasks.AzureEmulatorTasks.Run();
1617

1718
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, new Config());
19+
20+
Tasks.AzureEmulatorTasks.Cleanup();
21+
Console.WriteLine("// * AzureStorageEmulator: End *");
1822
}
1923

2024
private static void EnsureDBSetup()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace DotNetToolkit.Repository.Performance.Tasks
2+
{
3+
using System;
4+
using System.Threading;
5+
6+
public static class AzureEmulatorTasks
7+
{
8+
private static readonly object _syncRoot = new Object();
9+
private static int _count;
10+
private static IDisposable _runningTask;
11+
12+
public static void Run()
13+
{
14+
lock (_syncRoot)
15+
{
16+
if (Interlocked.Increment(ref _count) == 1)
17+
{
18+
_runningTask = Task.Run(
19+
"Tasks\\tools\\azure-storage-emulator",
20+
"AzureStorageEmulator.exe",
21+
"start -inprocess");
22+
}
23+
}
24+
}
25+
26+
public static void Cleanup()
27+
{
28+
lock (_syncRoot)
29+
{
30+
// Only stop when all tests have been completed
31+
if (Interlocked.Decrement(ref _count) == 0)
32+
{
33+
_runningTask.Dispose();
34+
}
35+
}
36+
}
37+
}
38+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
namespace DotNetToolkit.Repository.Performance.Tasks
2+
{
3+
using System;
4+
using System.Diagnostics;
5+
using System.IO;
6+
7+
public class Task
8+
{
9+
public static IDisposable Run(string basePath, string exe, string args = null)
10+
{
11+
var workingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, basePath);
12+
var fileName = Path.Combine(workingDirectory, exe);
13+
14+
var process = System.Diagnostics.Process.Start(new ProcessStartInfo
15+
{
16+
Arguments = args,
17+
FileName = fileName,
18+
WorkingDirectory = workingDirectory,
19+
WindowStyle = ProcessWindowStyle.Hidden
20+
});
21+
22+
return new KillProcess(process);
23+
}
24+
25+
private class KillProcess : IDisposable
26+
{
27+
private Process _process;
28+
29+
public KillProcess(Process process)
30+
{
31+
if (process == null)
32+
throw new ArgumentNullException(nameof(process));
33+
34+
_process = process;
35+
36+
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
37+
AppDomain.CurrentDomain.DomainUnload += CurrentDomain_ProcessExit;
38+
}
39+
40+
~KillProcess()
41+
{
42+
GC.WaitForPendingFinalizers();
43+
44+
Dispose();
45+
}
46+
47+
private void CurrentDomain_ProcessExit(object sender, EventArgs e)
48+
{
49+
Dispose();
50+
}
51+
52+
public void Dispose()
53+
{
54+
GC.SuppressFinalize(this);
55+
56+
if (_process != null && !_process.HasExited)
57+
{
58+
_process.Kill();
59+
_process.Dispose();
60+
_process = null;
61+
}
62+
}
63+
}
64+
}
65+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0"?>
2+
<configuration>
3+
<configSections>
4+
<section name="StorageEmulatorConfig" type="Microsoft.WindowsAzure.Storage.Emulator.Controller.Configuration.StorageEmulatorConfigurationHandler, Microsoft.Azure.Storage.Emulator.Controller"/>
5+
</configSections>
6+
7+
<StorageEmulatorConfig>
8+
<services>
9+
<service name="Blob" url="http://127.0.0.1:10000/"/>
10+
<service name="Queue" url="http://127.0.0.1:10001/"/>
11+
<service name="Table" url="http://127.0.0.1:10002/"/>
12+
</services>
13+
14+
<!-- NOTE: These are preconfigured accounts with well known keys. The purpose of the
15+
authentication supported by the Storage Emulator is simply to allow you to test
16+
your authentication code. It has no security purpose.
17+
It is strongly recommended that you DO NOT use your actual storage account or key over here.
18+
These keys are stored unencrypted on disk and in SQL databases.
19+
-->
20+
<accounts>
21+
<account name="devstoreaccount1" authKey="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" />
22+
</accounts>
23+
</StorageEmulatorConfig>
24+
<startup>
25+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
26+
</startup>
27+
<runtime>
28+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
29+
<dependentAssembly>
30+
<assemblyIdentity name="System.Windows.Forms" publicKeyToken="b77a5c561934e089" culture="neutral"/>
31+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
32+
</dependentAssembly>
33+
<dependentAssembly>
34+
<assemblyIdentity name="System.Core" publicKeyToken="b77a5c561934e089" culture="neutral"/>
35+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
36+
</dependentAssembly>
37+
<dependentAssembly>
38+
<assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture="neutral"/>
39+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
40+
</dependentAssembly>
41+
<dependentAssembly>
42+
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral"/>
43+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
44+
</dependentAssembly>
45+
<dependentAssembly>
46+
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral"/>
47+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
48+
</dependentAssembly>
49+
<dependentAssembly>
50+
<assemblyIdentity name="System.Drawing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
51+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
52+
</dependentAssembly>
53+
<dependentAssembly>
54+
<assemblyIdentity name="System.Runtime.Serialization" publicKeyToken="b77a5c561934e089" culture="neutral"/>
55+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
56+
</dependentAssembly>
57+
<dependentAssembly>
58+
<assemblyIdentity name="System.Data.Services" publicKeyToken="b77a5c561934e089" culture="neutral"/>
59+
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
60+
</dependentAssembly>
61+
<dependentAssembly>
62+
<assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture="neutral"/>
63+
<bindingRedirect oldVersion="2.0.0.0" newVersion="4.0.0.0"/>
64+
</dependentAssembly>
65+
</assemblyBinding>
66+
</runtime>
67+
</configuration>

0 commit comments

Comments
 (0)