diff --git a/test/Ocelot.Benchmarks/.gitignore b/test/Ocelot.Benchmarks/.gitignore new file mode 100644 index 00000000..0ca27f04 --- /dev/null +++ b/test/Ocelot.Benchmarks/.gitignore @@ -0,0 +1,234 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ diff --git a/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report-github.md b/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report-github.md new file mode 100755 index 00000000..ca7d330c --- /dev/null +++ b/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report-github.md @@ -0,0 +1,20 @@ +```ini + +Host Process Environment Information: +BenchmarkDotNet=v0.9.8.0 +OS=OSX +Processor=?, ProcessorCount=4 +Frequency=1000000000 ticks, Resolution=1.0000 ns, Timer=UNKNOWN +CLR=CORE, Arch=64-bit ? [RyuJIT] +GC=Concurrent Workstation +JitModules=? +dotnet cli version: 1.0.0-preview2-003121 + +Type=UrlPathToUrlPathTemplateMatcherBenchmarks Mode=Throughput Toolchain=Core +GarbageCollection=Concurrent Workstation + +``` + Method | Median | StdDev | Mean | StdError | StdDev | Op/s | Min | Q1 | Median | Q3 | Max | +----------- |------------ |---------- |------------ |---------- |---------- |----------- |------------ |------------ |------------ |------------ |------------ | + Benchmark1 | 180.4251 ns | 4.1294 ns | 180.4400 ns | 0.9234 ns | 4.1294 ns | 5542007.02 | 174.5503 ns | 177.6286 ns | 180.4251 ns | 182.5334 ns | 190.9792 ns | + Benchmark2 | 178.7267 ns | 6.1670 ns | 180.6081 ns | 1.3148 ns | 6.1670 ns | 5536849.8 | 174.0821 ns | 177.0992 ns | 178.7267 ns | 182.1962 ns | 198.1308 ns | diff --git a/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report.csv b/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report.csv new file mode 100755 index 00000000..2f7488c0 --- /dev/null +++ b/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report.csv @@ -0,0 +1,3 @@ +Type;Method;Mode;Platform;Jit;Toolchain;Runtime;GarbageCollection;LaunchCount;WarmupCount;TargetCount;Affinity;Median;StdDev;Mean;StdError;StdDev;Op/s;Min;Q1;Median;Q3;Max +UrlPathToUrlPathTemplateMatcherBenchmarks;Benchmark1;Throughput;Host;Host;Core;Host;Concurrent Workstation;Auto;Auto;Auto;Auto;180.4251 ns;4.1294 ns;180.4400 ns;0.9234 ns;4.1294 ns;5542007.02;174.5503 ns;177.6286 ns;180.4251 ns;182.5334 ns;190.9792 ns +UrlPathToUrlPathTemplateMatcherBenchmarks;Benchmark2;Throughput;Host;Host;Core;Host;Concurrent Workstation;Auto;Auto;Auto;Auto;178.7267 ns;6.1670 ns;180.6081 ns;1.3148 ns;6.1670 ns;5536849.8;174.0821 ns;177.0992 ns;178.7267 ns;182.1962 ns;198.1308 ns diff --git a/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report.html b/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report.html new file mode 100755 index 00000000..229b23f1 --- /dev/null +++ b/test/Ocelot.Benchmarks/BenchmarkDotNet.Artifacts/results/UrlPathToUrlPathTemplateMatcherBenchmarks-report.html @@ -0,0 +1,20 @@ +

+Host Process Environment Information:
+BenchmarkDotNet=v0.9.8.0
+OS=OSX
+Processor=?, ProcessorCount=4
+Frequency=1000000000 ticks, Resolution=1.0000 ns, Timer=UNKNOWN
+CLR=CORE, Arch=64-bit ? [RyuJIT]
+GC=Concurrent Workstation
+JitModules=?
+dotnet cli version: 1.0.0-preview2-003121
+
+
Type=UrlPathToUrlPathTemplateMatcherBenchmarks  Mode=Throughput  Toolchain=Core  
+GarbageCollection=Concurrent Workstation  
+
+ + + + + +
MethodMedianStdDev MeanStdErrorStdDevOp/s Min Q1Median Q3 Max
Benchmark1180.4251 ns4.1294 ns180.4400 ns0.9234 ns4.1294 ns5542007.02174.5503 ns177.6286 ns180.4251 ns182.5334 ns190.9792 ns
Benchmark2178.7267 ns6.1670 ns180.6081 ns1.3148 ns6.1670 ns5536849.8174.0821 ns177.0992 ns178.7267 ns182.1962 ns198.1308 ns
diff --git a/test/Ocelot.Benchmarks/Program.cs b/test/Ocelot.Benchmarks/Program.cs new file mode 100644 index 00000000..1ff2bc92 --- /dev/null +++ b/test/Ocelot.Benchmarks/Program.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BenchmarkDotNet.Running; + +namespace Ocelot.Benchmarks +{ + public class Program + { + public static void Main(string[] args) + { + var summary = BenchmarkRunner.Run(); + } + } +} diff --git a/test/Ocelot.Benchmarks/UrlPathToUrlPathTemplateMatcherBenchmarks.cs b/test/Ocelot.Benchmarks/UrlPathToUrlPathTemplateMatcherBenchmarks.cs new file mode 100644 index 00000000..c88cbc69 --- /dev/null +++ b/test/Ocelot.Benchmarks/UrlPathToUrlPathTemplateMatcherBenchmarks.cs @@ -0,0 +1,42 @@ +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Columns; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Jobs; +using Ocelot.Library.Infrastructure.UrlPathMatcher; + + +namespace Ocelot.Benchmarks +{ + [Config(typeof(UrlPathToUrlPathTemplateMatcherBenchmarks))] + public class UrlPathToUrlPathTemplateMatcherBenchmarks : ManualConfig + { + private UrlPathToUrlPathTemplateMatcher _urlPathMatcher; + private string _downstreamUrlPath; + private string _downstreamUrlPathTemplate; + + public UrlPathToUrlPathTemplateMatcherBenchmarks() + { + Add(StatisticColumn.AllStatistics); + } + + [Setup] + public void SetUp() + { + _urlPathMatcher = new UrlPathToUrlPathTemplateMatcher(); + _downstreamUrlPath = "api/product/products/1/variants/?soldout=false"; + _downstreamUrlPathTemplate = "api/product/products/{productId}/variants/"; + } + + [Benchmark] + public void Benchmark1() + { + _urlPathMatcher.Match(_downstreamUrlPath, _downstreamUrlPathTemplate); + } + + [Benchmark] + public void Benchmark2() + { + _urlPathMatcher.Match(_downstreamUrlPath, _downstreamUrlPathTemplate); + } + } +} \ No newline at end of file diff --git a/test/Ocelot.Benchmarks/project.json b/test/Ocelot.Benchmarks/project.json new file mode 100644 index 00000000..da710bc9 --- /dev/null +++ b/test/Ocelot.Benchmarks/project.json @@ -0,0 +1,28 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true + }, + + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "BenchmarkDotNet": "0.9.8", + "Ocelot.Library": "1.0.0-*" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "tooling": { + "defaultNamespace": "Ocelot.Benchmarks" + } +}