Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
benchmark update #50
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTeixeira committed May 1, 2019
1 parent b7ec859 commit b182c37
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<_Parameter1>$(MSBuildProjectName).Test</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Benchmark</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Localization">
<HintPath>..\..\..\..\..\usr\local\share\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.localization\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Localization.dll</HintPath>
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,21 @@ Intel Core i7-5557U CPU 3.10GHz (Broadwell), 1 CPU, 4 logical and 2 physical cor

``` ini

BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.3 (18D109) [Darwin 18.2.0]
BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.4 (18E226) [Darwin 18.5.0]
Intel Core i7-5557U CPU 3.10GHz (Broadwell), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=2.2.100
[Host] : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT [AttachedDebugger]
DefaultJob : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT
.NET Core SDK=2.2.106
[Host] : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT
DefaultJob : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT


```
| Method | Mean | Error | StdDev | Min | Max | Ratio | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
|-------------- |----------:|----------:|----------:|----------:|----------:|------:|------------:|------------:|------------:|--------------------:|
| JsonLocalizer | 72.69 ns | 0.2973 ns | 0.2483 ns | 72.35 ns | 73.34 ns | 0.57 | 0.0228 | - | - | 48 B |
| Localizer | 126.99 ns | 1.8120 ns | 1.6950 ns | 124.92 ns | 130.10 ns | 1.00 | - | - | - | - |
| Method | Mean | Error | StdDev | Min | Max | Ratio | RatioSD | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
|------------------------------------------------ |--------------:|--------------:|--------------:|--------------:|--------------:|---------:|--------:|------------:|------------:|------------:|--------------------:|
| JsonLocalizer | 68.83 ns | 0.1259 ns | 0.1116 ns | 68.58 ns | 68.95 ns | 0.63 | 0.00 | 0.0228 | - | - | 48 B |
| JsonLocalizerWithCreation | 512,929.54 ns | 1,795.6669 ns | 1,679.6679 ns | 510,100.03 ns | 515,499.84 ns | 4,678.08 | 13.62 | 83.0078 | 29.2969 | 4.8828 | 174968 B |
| JsonLocalizerWithCreationAndExternalMemoryCache | 4,930.42 ns | 20.7277 ns | 18.3746 ns | 4,888.34 ns | 4,956.98 ns | 44.98 | 0.18 | 1.7624 | 0.8774 | - | 3712 B |
| Localizer | 109.62 ns | 0.1763 ns | 0.1563 ns | 109.48 ns | 110.05 ns | 1.00 | 0.00 | - | - | - | - |



# Contributors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.3 (18D109) [Darwin 18.2.0]
BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.4 (18E226) [Darwin 18.5.0]
Intel Core i7-5557U CPU 3.10GHz (Broadwell), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=2.2.100
[Host] : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT [AttachedDebugger]
DefaultJob : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT
.NET Core SDK=2.2.106
[Host] : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT
DefaultJob : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT


Method | Mean | Error | StdDev | Min | Max | Ratio | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
-------------- |----------:|----------:|----------:|----------:|----------:|------:|------------:|------------:|------------:|--------------------:|
JsonLocalizer | 72.69 ns | 0.2973 ns | 0.2483 ns | 72.35 ns | 73.34 ns | 0.57 | 0.0228 | - | - | 48 B |
Localizer | 126.99 ns | 1.8120 ns | 1.6950 ns | 124.92 ns | 130.10 ns | 1.00 | - | - | - | - |
Method | Mean | Error | StdDev | Min | Max | Ratio | RatioSD | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
------------------------------------------------ |--------------:|--------------:|--------------:|--------------:|--------------:|---------:|--------:|------------:|------------:|------------:|--------------------:|
JsonLocalizer | 68.83 ns | 0.1259 ns | 0.1116 ns | 68.58 ns | 68.95 ns | 0.63 | 0.00 | 0.0228 | - | - | 48 B |
JsonLocalizerWithCreation | 512,929.54 ns | 1,795.6669 ns | 1,679.6679 ns | 510,100.03 ns | 515,499.84 ns | 4,678.08 | 13.62 | 83.0078 | 29.2969 | 4.8828 | 174968 B |
JsonLocalizerWithCreationAndExternalMemoryCache | 4,930.42 ns | 20.7277 ns | 18.3746 ns | 4,888.34 ns | 4,956.98 ns | 44.98 | 0.18 | 1.7624 | 0.8774 | - | 3712 B |
Localizer | 109.62 ns | 0.1763 ns | 0.1563 ns | 109.48 ns | 110.05 ns | 1.00 | 0.00 | - | - | - | - |
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
``` ini

BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.3 (18D109) [Darwin 18.2.0]
BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.4 (18E226) [Darwin 18.5.0]
Intel Core i7-5557U CPU 3.10GHz (Broadwell), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=2.2.100
[Host] : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT [AttachedDebugger]
DefaultJob : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT
.NET Core SDK=2.2.106
[Host] : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT
DefaultJob : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT


```
| Method | Mean | Error | StdDev | Min | Max | Ratio | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
|-------------- |----------:|----------:|----------:|----------:|----------:|------:|------------:|------------:|------------:|--------------------:|
| JsonLocalizer | 72.69 ns | 0.2973 ns | 0.2483 ns | 72.35 ns | 73.34 ns | 0.57 | 0.0228 | - | - | 48 B |
| Localizer | 126.99 ns | 1.8120 ns | 1.6950 ns | 124.92 ns | 130.10 ns | 1.00 | - | - | - | - |
| Method | Mean | Error | StdDev | Min | Max | Ratio | RatioSD | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
|------------------------------------------------ |--------------:|--------------:|--------------:|--------------:|--------------:|---------:|--------:|------------:|------------:|------------:|--------------------:|
| JsonLocalizer | 68.83 ns | 0.1259 ns | 0.1116 ns | 68.58 ns | 68.95 ns | 0.63 | 0.00 | 0.0228 | - | - | 48 B |
| JsonLocalizerWithCreation | 512,929.54 ns | 1,795.6669 ns | 1,679.6679 ns | 510,100.03 ns | 515,499.84 ns | 4,678.08 | 13.62 | 83.0078 | 29.2969 | 4.8828 | 174968 B |
| JsonLocalizerWithCreationAndExternalMemoryCache | 4,930.42 ns | 20.7277 ns | 18.3746 ns | 4,888.34 ns | 4,956.98 ns | 44.98 | 0.18 | 1.7624 | 0.8774 | - | 3712 B |
| Localizer | 109.62 ns | 0.1763 ns | 0.1563 ns | 109.48 ns | 110.05 ns | 1.00 | 0.00 | - | - | - | - |
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Method Job AnalyzeLaunchVariance EvaluateOverhead MaxAbsoluteError MaxRelativeError MinInvokeCount MinIterationTime OutlierMode Affinity EnvironmentVariables Jit Platform Runtime AllowVeryLargeObjects Concurrent CpuGroups Force HeapAffinitizeMask HeapCount NoAffinitize RetainVm Server Arguments BuildConfiguration Clock EngineFactory NuGetReferences Toolchain IsMutator InvocationCount IterationCount IterationTime LaunchCount MaxIterationCount MaxWarmupIterationCount MinIterationCount MinWarmupIterationCount RunStrategy UnrollFactor WarmupCount Mean Error StdDev Min Max Ratio Gen 0/1k Op Gen 1/1k Op Gen 2/1k Op Allocated Memory/Op
JsonLocalizer Default False Default Default Default Default Default Default 0000 Empty RyuJit X64 Core False True False True Default Default False False False Default Default Default Default Default Default Default 1 Default Default Default Default Default Default Default Default 16 Default 72.69 ns 0.2973 ns 0.2483 ns 72.35 ns 73.34 ns 0.57 0.0228 - - 48 B
Localizer Default False Default Default Default Default Default Default 0000 Empty RyuJit X64 Core False True False True Default Default False False False Default Default Default Default Default Default Default 1 Default Default Default Default Default Default Default Default 16 Default 126.99 ns 1.8120 ns 1.6950 ns 124.92 ns 130.10 ns 1.00 - - - -
Method Job AnalyzeLaunchVariance EvaluateOverhead MaxAbsoluteError MaxRelativeError MinInvokeCount MinIterationTime OutlierMode Affinity EnvironmentVariables Jit Platform Runtime AllowVeryLargeObjects Concurrent CpuGroups Force HeapAffinitizeMask HeapCount NoAffinitize RetainVm Server Arguments BuildConfiguration Clock EngineFactory NuGetReferences Toolchain IsMutator InvocationCount IterationCount IterationTime LaunchCount MaxIterationCount MaxWarmupIterationCount MinIterationCount MinWarmupIterationCount RunStrategy UnrollFactor WarmupCount Mean Error StdDev Min Max Ratio RatioSD Gen 0/1k Op Gen 1/1k Op Gen 2/1k Op Allocated Memory/Op
JsonLocalizer Default False Default Default Default Default Default Default 0000 Empty RyuJit X64 Core False True False True Default Default False False False Default Default Default Default Default Default Default 1 Default Default Default Default Default Default Default Default 16 Default 68.83 ns 0.1259 ns 0.1116 ns 68.58 ns 68.95 ns 0.63 0.00 0.0228 - - 48 B
JsonLocalizerWithCreation Default False Default Default Default Default Default Default 0000 Empty RyuJit X64 Core False True False True Default Default False False False Default Default Default Default Default Default Default 1 Default Default Default Default Default Default Default Default 16 Default "512,929.54 ns" "1,795.6669 ns" "1,679.6679 ns" "510,100.03 ns" "515,499.84 ns" "4,678.08" 13.62 83.0078 29.2969 4.8828 174968 B
JsonLocalizerWithCreationAndExternalMemoryCache Default False Default Default Default Default Default Default 0000 Empty RyuJit X64 Core False True False True Default Default False False False Default Default Default Default Default Default Default 1 Default Default Default Default Default Default Default Default 16 Default "4,930.42 ns" 20.7277 ns 18.3746 ns "4,888.34 ns" "4,956.98 ns" 44.98 0.18 1.7624 0.8774 - 3712 B
Localizer Default False Default Default Default Default Default Default 0000 Empty RyuJit X64 Core False True False True Default Default False False False Default Default Default Default Default Default Default 1 Default Default Default Default Default Default Default Default 16 Default 109.62 ns 0.1763 ns 0.1563 ns 109.48 ns 110.05 ns 1.00 0.00 - - - -
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.3 (18D109) [Darwin 18.2.0]
BenchmarkDotNet=v0.11.3, OS=macOS Mojave 10.14.4 (18E226) [Darwin 18.5.0]
Intel Core i7-5557U CPU 3.10GHz (Broadwell), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=2.2.100
[Host] : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT [AttachedDebugger]
DefaultJob : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT
.NET Core SDK=2.2.106
[Host] : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT
DefaultJob : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT
</code></pre>
<pre><code></code></pre>

<table>
<thead><tr><th> Method</th><th>Mean</th><th>Error</th><th>StdDev</th><th>Min</th><th>Max</th><th>Ratio</th><th>Gen 0/1k Op</th><th>Gen 1/1k Op</th><th>Gen 2/1k Op</th><th>Allocated Memory/Op</th>
<thead><tr><th> Method</th><th> Mean</th><th> Error</th><th> StdDev</th><th> Min</th><th> Max</th><th>Ratio</th><th>RatioSD</th><th>Gen 0/1k Op</th><th>Gen 1/1k Op</th><th>Gen 2/1k Op</th><th>Allocated Memory/Op</th>
</tr>
</thead><tbody><tr><td>JsonLocalizer</td><td>72.69 ns</td><td>0.2973 ns</td><td>0.2483 ns</td><td>72.35 ns</td><td>73.34 ns</td><td>0.57</td><td>0.0228</td><td>-</td><td>-</td><td>48 B</td>
</tr><tr><td>Localizer</td><td>126.99 ns</td><td>1.8120 ns</td><td>1.6950 ns</td><td>124.92 ns</td><td>130.10 ns</td><td>1.00</td><td>-</td><td>-</td><td>-</td><td>-</td>
</thead><tbody><tr><td>JsonLocalizer</td><td>68.83 ns</td><td>0.1259 ns</td><td>0.1116 ns</td><td>68.58 ns</td><td>68.95 ns</td><td>0.63</td><td>0.00</td><td>0.0228</td><td>-</td><td>-</td><td>48 B</td>
</tr><tr><td>JsonLocalizerWithCreation</td><td>512,929.54 ns</td><td>1,795.6669 ns</td><td>1,679.6679 ns</td><td>510,100.03 ns</td><td>515,499.84 ns</td><td>4,678.08</td><td>13.62</td><td>83.0078</td><td>29.2969</td><td>4.8828</td><td>174968 B</td>
</tr><tr><td>JsonLocalizerWithCreationAndExternalMemoryCache</td><td>4,930.42 ns</td><td>20.7277 ns</td><td>18.3746 ns</td><td>4,888.34 ns</td><td>4,956.98 ns</td><td>44.98</td><td>0.18</td><td>1.7624</td><td>0.8774</td><td>-</td><td>3712 B</td>
</tr><tr><td>Localizer</td><td>109.62 ns</td><td>0.1763 ns</td><td>0.1563 ns</td><td>109.48 ns</td><td>110.05 ns</td><td>1.00</td><td>0.00</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr></tbody></table>
</body>
</html>
73 changes: 58 additions & 15 deletions benchmark/Askmethat.Aspnet.JsonLocalizer.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,79 @@
using Microsoft.Extensions.DependencyInjection;
using Askmethat.Aspnet.JsonLocalizer.Benchmark.Resources;
using System.Reflection;
using Microsoft.Extensions.FileProviders;

namespace Askmethat.Aspnet.JsonLocalizer.Benchmark
{
public class HostingEnvironmentStub : IHostingEnvironment
{
public HostingEnvironmentStub()
{
}

public string EnvironmentName { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string ApplicationName { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string WebRootPath { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public IFileProvider WebRootFileProvider { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string ContentRootPath { get => AppContext.BaseDirectory; set => throw new NotImplementedException(); }
public IFileProvider ContentRootFileProvider { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}

[MinColumn, MaxColumn, MemoryDiagnoser, MarkdownExporter]
public class BenchmarkJSONLocalizer
{
IHostingEnvironment env = new HostingEnvironment();
IMemoryCache _cach = new MemoryCache(Options.Create<MemoryCacheOptions>(new MemoryCacheOptions() {

}));
private const int N = 10000;
IStringLocalizer _jsonLocalizer;

public BenchmarkJSONLocalizer()
{
var serviceProvider = new ServiceCollection()
.AddLocalization(opts => { opts.ResourcesPath = "Resources"; })
.BuildServiceProvider();
_jsonLocalizer = new JsonStringLocalizer(Options.Create<JsonLocalizationOptions>(new JsonLocalizationOptions()
{
DefaultCulture = new CultureInfo("fr-FR"),
ResourcesPath = "Resources"
}), new HostingEnvironmentStub());
}

[Benchmark]
public string JsonLocalizer() => _jsonLocalizer.GetString("BaseName1");

[Benchmark]
public string JsonLocalizerWithCreation()
{
var localizer = new JsonStringLocalizer(Options.Create<JsonLocalizationOptions>(new JsonLocalizationOptions()
{
DefaultCulture = new CultureInfo("fr-FR"),
ResourcesPath = "Resources",
SupportedCultureInfos = new System.Collections.Generic.HashSet<CultureInfo>()
{
new CultureInfo("fr-FR"),
new CultureInfo("en-US"),
}
}), new HostingEnvironmentStub());

_jsonLocalizer = serviceProvider.GetService<IStringLocalizer>();
return localizer.GetString("BaseName1");
}

[Benchmark]
public string JsonLocalizer() {
System.Diagnostics.Debug.WriteLine(_jsonLocalizer.GetString("BaseName1"));
return _jsonLocalizer.GetString("BaseName1");
public string JsonLocalizerWithCreationAndExternalMemoryCache()
{
var localizer = new JsonStringLocalizer(Options.Create<JsonLocalizationOptions>(new JsonLocalizationOptions()
{
DefaultCulture = new CultureInfo("fr-FR"),
ResourcesPath = "Resources",
SupportedCultureInfos = new System.Collections.Generic.HashSet<CultureInfo>()
{
new CultureInfo("fr-FR"),
new CultureInfo("en-US"),
},
Caching = _cach
}), new HostingEnvironmentStub());

return localizer.GetString("BaseName1");
}


Expand All @@ -47,14 +97,7 @@ class Program
{
static void Main(string[] args)
{
//IHostingEnvironment env = new HostingEnvironment();
//var t = new JsonStringLocalizerFactory(env);
//var x = t.Create("", "");
//x.GetString("BaseName1");
//x.GetString("BaseName2");
var summary = BenchmarkRunner.Run<BenchmarkJSONLocalizer>();


BenchmarkRunner.Run<BenchmarkJSONLocalizer>();
}
}
}

0 comments on commit b182c37

Please sign in to comment.