Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Benchmark MLOps.NET #320

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BenchmarkDotNet.Attributes;
using System.Threading.Tasks;

namespace MLOps.NET.Benchmarks
{
public class LifeCycleCatalogAzureBenchmark
{
private IMLOpsContext sut;

[GlobalSetup]
public void Initialize()
{
sut = BenchmarkSetup.InitializeAzure();
}

[Benchmark]
public async Task CreateRunAsync()
{
await sut.LifeCycle.CreateRunAsync("Benchmark Azure");
}
}
}
30 changes: 30 additions & 0 deletions Benchmarks/MLOps.NET.Benchmarks/Benchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using BenchmarkDotNet.Running;

namespace MLOps.NET.Benchmarks
{
public class Benchmark
{
public static void Main(string[] args)
{
SQLiteBenchmarks();
SQLServerBenchmarks();
SQLServerAzure();
}

public static void SQLiteBenchmarks()
{
var lifeCycleCatalogBenchmarks = BenchmarkRunner.Run<LifeCycleCatalogSQLiteBenchmark>();
}

public static void SQLServerBenchmarks()
{
var lifeCycleCatalogBenchmarks = BenchmarkRunner.Run<LifeCycleCatalogSQLServerBenchmark>();
}

public static void SQLServerAzure()
{
var lifeCycleCatalogBenchmarks = BenchmarkRunner.Run<LifeCycleCatalogAzureBenchmark>();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Extensions.Configuration;

namespace MLOps.NET.Benchmarks
{
public static class ConfigurationFactory
{
public static IConfiguration GetConfiguration(string configuration)
{
return new ConfigurationBuilder()
.AddJsonFile(configuration)
.AddEnvironmentVariables()
.Build();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MLOps.NET.Benchmarks
{
internal class ConfigurationKeysAzure
{
public static string StorageAccount = "StorageAccount:ConnectionString";
public static string CosmosEndPoint = "Cosmos:Endpoint";
public static string CosmosAccountKey = "Cosmos:AccountKey";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace MLOps.NET.Benchmarks
{
internal class ConfigurationKeysSQLServer
{
public static string ConnectionString = "SQLServer:ConnectionString";
}
}
33 changes: 33 additions & 0 deletions Benchmarks/MLOps.NET.Benchmarks/MLOps.NET.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.7" />
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="Moq" Version="4.14.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MLOps.NET.AWS\MLOps.NET.AWS.csproj" />
<ProjectReference Include="..\..\src\MLOps.NET.Azure\MLOps.NET.Azure.csproj" />
<ProjectReference Include="..\..\src\MLOps.NET.SQLite\MLOps.NET.SQLite.csproj" />
<ProjectReference Include="..\..\src\MLOps.NET.SQLServer\MLOps.NET.SQLServer.csproj" />
<ProjectReference Include="..\..\src\MLOps.NET\MLOps.NET.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Settings\appsettingsazure.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Settings\appsettingssqlserver.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BenchmarkDotNet.Attributes;
using System.Threading.Tasks;

namespace MLOps.NET.Benchmarks
{
public class LifeCycleCatalogSQLServerBenchmark
{
private IMLOpsContext sut;

[GlobalSetup]
public void Initialize()
{
sut = BenchmarkSetup.InitializeSQLServer();
}

[Benchmark]
public async Task CreateRunAsync()
{
await sut.LifeCycle.CreateRunAsync("Benchmark SQLServer");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BenchmarkDotNet.Attributes;
using System.Threading.Tasks;

namespace MLOps.NET.Benchmarks
{
public class LifeCycleCatalogSQLiteBenchmark
{
private IMLOpsContext sut;

[GlobalSetup]
public void Initialize()
{
sut = BenchmarkSetup.InitializeSQLite();
}

[Benchmark]
public async Task CreateRunAsync()
{
await sut.LifeCycle.CreateRunAsync("Benchmark SQLite");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"StorageAccount": {
"ConnectionString": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"
},
"Cosmos": {
"Endpoint": "https://localhost:8081",
"AccountKey": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"SQLServer": {
"ConnectionString": "Server=localhost,1433;Database=MLOpsNET_IntegrationTests;User Id=sa;Password=MLOps4TheWin!;"
}
}
41 changes: 41 additions & 0 deletions Benchmarks/MLOps.NET.Benchmarks/Setup/BenchmarkSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using MLOps.NET.Azure;
using MLOps.NET.Extensions;
using MLOps.NET.SQLite;
using MLOps.NET.SQLServer;

namespace MLOps.NET.Benchmarks
{
internal class BenchmarkSetup
{
internal static IMLOpsContext InitializeSQLite()
{
return new MLOpsBuilder()
.UseLocalFileModelRepository()
.UseSQLite()
.Build();
}

internal static IMLOpsContext InitializeSQLServer()
{
var configuration = ConfigurationFactory.GetConfiguration("appsettingssqlserver.json");

return new MLOpsBuilder()
.UseLocalFileModelRepository()
.UseSQLServer(configuration[ConfigurationKeysSQLServer.ConnectionString])
.Build();
}

internal static IMLOpsContext InitializeAzure()
{
var configuration = ConfigurationFactory.GetConfiguration("appsettingsazure.json");

return new MLOpsBuilder()
.UseLocalFileModelRepository()
.UseCosmosDb(configuration[ConfigurationKeysAzure.CosmosEndPoint],
configuration[ConfigurationKeysAzure.CosmosAccountKey])
.Build();
}
}
}


9 changes: 9 additions & 0 deletions MLOps.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MLOps.NET.AWS.Tests", "test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MLOps.NET.AWS.IntegrationTests", "test\MLOps.NET.AWS.IntegrationTests\MLOps.NET.AWS.IntegrationTests.csproj", "{A45E6A71-DF5B-49DB-B78C-864740A81D6F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks", "{8AB880D4-678B-4DDF-A560-D07F0301519A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLOps.NET.Benchmarks", "Benchmarks\MLOps.NET.Benchmarks\MLOps.NET.Benchmarks.csproj", "{7547EBD6-6D86-4C83-8B0F-0E85526AA667}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -103,6 +107,10 @@ Global
{A45E6A71-DF5B-49DB-B78C-864740A81D6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A45E6A71-DF5B-49DB-B78C-864740A81D6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A45E6A71-DF5B-49DB-B78C-864740A81D6F}.Release|Any CPU.Build.0 = Release|Any CPU
{7547EBD6-6D86-4C83-8B0F-0E85526AA667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7547EBD6-6D86-4C83-8B0F-0E85526AA667}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7547EBD6-6D86-4C83-8B0F-0E85526AA667}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7547EBD6-6D86-4C83-8B0F-0E85526AA667}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -123,6 +131,7 @@ Global
{F8403022-3BE3-4491-A0E7-4E8EE0338957} = {BFA1E5BE-95E8-4A9B-BE55-8EFA8F8488F1}
{8EF5AE0B-17DC-4909-8298-31AC27377184} = {D826364F-D0C6-4FB9-A4D1-837372F6367C}
{A45E6A71-DF5B-49DB-B78C-864740A81D6F} = {D826364F-D0C6-4FB9-A4D1-837372F6367C}
{7547EBD6-6D86-4C83-8B0F-0E85526AA667} = {8AB880D4-678B-4DDF-A560-D07F0301519A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {44F93107-BB01-4A51-BBCB-A475BE891E6A}
Expand Down