You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ocelot/test/Ocelot.Benchmarks/UrlPathToUrlPathTemplateMat...

52 lines
2.1 KiB
C#

using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Validators;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
namespace Ocelot.Benchmarks
{
[Config(typeof(UrlPathToUrlPathTemplateMatcherBenchmarks))]
public class UrlPathToUrlPathTemplateMatcherBenchmarks : ManualConfig
{
private RegExUrlMatcher _urlPathMatcher;
private string _downstreamUrlPath;
private string _downstreamUrlPathTemplate;
private string _upstreamQuery;
public UrlPathToUrlPathTemplateMatcherBenchmarks()
{
Add(StatisticColumn.AllStatistics);
Add(MemoryDiagnoser.Default);
Add(BaselineValidator.FailOnError);
}
[GlobalSetup]
public void SetUp()
{
_urlPathMatcher = new RegExUrlMatcher();
_downstreamUrlPath = "api/product/products/1/variants/?soldout=false";
_downstreamUrlPathTemplate = "api/product/products/{productId}/variants/";
}
[Benchmark(Baseline = true)]
public void Baseline()
{
_urlPathMatcher.Match(_downstreamUrlPath, _upstreamQuery, _downstreamUrlPathTemplate, false);
}
// * Summary *
// BenchmarkDotNet=v0.10.13, OS=macOS 10.12.6 (16G1212) [Darwin 16.7.0]
// Intel Core i5-4278U CPU 2.60GHz (Haswell), 1 CPU, 4 logical cores and 2 physical cores
// .NET Core SDK=2.1.4
// [Host] : .NET Core 2.0.6 (CoreCLR 4.6.0.0, CoreFX 4.6.26212.01), 64bit RyuJIT
// DefaultJob : .NET Core 2.0.6 (CoreCLR 4.6.0.0, CoreFX 4.6.26212.01), 64bit RyuJIT
// Method | Mean | Error | StdDev | StdErr | Min | Q1 | Median | Q3 | Max | Op/s |
// ----------- |---------:|----------:|----------:|----------:|---------:|---------:|---------:|---------:|---------:|----------:|
// Benchmark1 | 3.133 us | 0.0492 us | 0.0460 us | 0.0119 us | 3.082 us | 3.100 us | 3.122 us | 3.168 us | 3.233 us | 319,161.9 |
}
}