Skip to content
Merged
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
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<PackageVersion Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.2.3" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.1.22" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.1" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions WebJobs.Extensions.Sql.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.WebJobs.Extensions.Sql.Performance", "performance\Microsoft.Azure.WebJobs.Extensions.Sql.Performance.csproj", "{1A5148B7-F877-4813-852C-F94D6EF795E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "performance", "performance", "{F0F3562F-9176-4461-98E4-13D38D3DD056}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -38,6 +42,10 @@ Global
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1}.Release|Any CPU.Build.0 = Release|Any CPU
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A5148B7-F877-4813-852C-F94D6EF795E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -46,6 +54,7 @@ Global
{B2E0EFB9-BEDB-48F7-BD5A-0E1010333475} = {3691FB44-971D-43FD-9B2F-916B8CE689DB}
{4453B407-2CA3-4011-BDE5-247FCE5C1974} = {21CDC01C-247B-46B0-A8F5-9D35686C628B}
{A5B55530-71C8-4A9A-92AD-1D33A5E80FC1} = {F7E99EB5-47D3-4B50-A6AA-D8D5508A121A}
{1A5148B7-F877-4813-852C-F94D6EF795E8} = {F0F3562F-9176-4461-98E4-13D38D3DD056}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {49902AA5-150F-4567-B562-4AA8549B2CF4}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- Need to set root namespace to empty for IDE0130 to work properly - otherwise it errors out on top-level namespaces for some reason -->
<RootNamespace></RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\test\Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj" />
<ProjectReference Include="..\samples\samples-csharp\Microsoft.Azure.WebJobs.Extensions.Sql.Samples.csproj" />
</ItemGroup>

<Target Name="CopySamples" AfterTargets="Build">
<ItemGroup>
<_CSharpCopyItems Include="..\samples\samples-csharp\bin\$(Configuration)\$(TargetFramework)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(_CSharpCopyItems)" DestinationFolder="$(OutDir)\SqlExtensionSamples\CSharp\%(RecursiveDir)" />
<Message Text="Copied C# Samples output to $(OutDir)\SqlExtensionSamples\CSharp" Importance="high" />
</Target>

<!-- Copy C# Samples output to BenchmarkDotNet project bin (https://github.com/dotnet/BenchmarkDotNet/issues/946) -->
<ItemGroup>
<None Include="$(OutDir)\**\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>%(RecursiveDir)\%(Filename)%(Extension)</Link>
<Visible>True</Visible>
</None>
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions performance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Running Performance Tests

## Pre-requisites
The performance tests are based on the IntegrationTestBase class. Follow the instructions to set up the pre-requisites for integration tests [here](../test/README.md#running-integration-tests).

## Run
The performance tests use BenchmarkDotNet to benchmark performance for input and output bindings.

Run the tests from the terminal.
```
cd performance
dotnet run -c Release
```

## Results
The test results will be generated in the BenchmarkDotNet.Artifacts folder.
16 changes: 16 additions & 0 deletions performance/SqlBindingBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using BenchmarkDotNet.Running;

namespace Microsoft.Azure.WebJobs.Extensions.Sql.Performance
{
public class SqlBindingPerformance
{
public static void Main()
{
BenchmarkRunner.Run<SqlInputBindingPerformance>();
BenchmarkRunner.Run<SqlOutputBindingPerformance>();
}
}
}
41 changes: 41 additions & 0 deletions performance/SqlInputBindingPerformance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common;
using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.InputBindingSamples;
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Common;
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration;
using BenchmarkDotNet.Attributes;

namespace Microsoft.Azure.WebJobs.Extensions.Sql.Performance
{
public class SqlInputBindingPerformance : IntegrationTestBase
{
[GlobalSetup]
public void GlobalSetup()
{
this.StartFunctionHost(nameof(GetProductsTopN), SupportedLanguages.CSharp);
Product[] products = GetProductsWithSameCost(10000, 100);
this.InsertProducts(products);
}

[Benchmark]
[Arguments("1")]
[Arguments("10")]
[Arguments("100")]
[Arguments("1000")]
[Arguments("10000")]
public async Task<HttpResponseMessage> GetProductsTest(string count)
{
return await this.SendInputRequest("getproductstopn", count);
}

[GlobalCleanup]
public void GlobalCleanup()
{
this.Dispose();
}
}
}
49 changes: 49 additions & 0 deletions performance/SqlOutputBindingPerformance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration;
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Common;
using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.Common;
using Microsoft.Azure.WebJobs.Extensions.Sql.Samples.OutputBindingSamples;
using Newtonsoft.Json;
using BenchmarkDotNet.Attributes;


namespace Microsoft.Azure.WebJobs.Extensions.Sql.Performance
{
public class SqlOutputBindingPerformance : IntegrationTestBase
{
[GlobalSetup]
public void StartAddProductsArrayFunction()
{
this.StartFunctionHost(nameof(AddProductsArray), SupportedLanguages.CSharp);
}

[Benchmark]
[Arguments(1)]
[Arguments(10)]
[Arguments(100)]
[Arguments(1000)]
public async Task<HttpResponseMessage> AddProductsArrayTest(int count)
{
Product[] productsToAdd = GetProductsWithSameCost(count, 100);
return await this.SendOutputPostRequest("addproducts-array", JsonConvert.SerializeObject(productsToAdd));
}

[IterationCleanup]
public void IterationCleanup()
{
// Delete all rows in Products table after each iteration
this.ExecuteNonQuery("TRUNCATE TABLE Products");
}

[GlobalCleanup]
public void GlobalCleanup()
{
// Delete the database
this.Dispose();
}
}
}
Loading