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
9 changes: 8 additions & 1 deletion StackExchange.Redis.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
tests\RedisConfigs\docker-compose.yml = tests\RedisConfigs\docker-compose.yml
global.json = global.json
NuGet.Config = NuGet.Config
README.md = README.md
docs\ReleaseNotes.md = docs\ReleaseNotes.md
Shared.ruleset = Shared.ruleset
version.json = version.json
tests\RedisConfigs\docker-compose.yml = tests\RedisConfigs\docker-compose.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RedisConfigs", "RedisConfigs", "{96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}"
Expand Down Expand Up @@ -120,6 +120,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTestBaseline", "test
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "docs", "docs\docs.csproj", "{1DC43E76-5372-4C7F-A433-0602273E87FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchange.Redis.Benchmarks", "tests\StackExchange.Redis.Benchmarks\StackExchange.Redis.Benchmarks.csproj", "{59889284-FFEE-82E7-94CB-3B43E87DA6CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -174,6 +176,10 @@ Global
{1DC43E76-5372-4C7F-A433-0602273E87FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DC43E76-5372-4C7F-A433-0602273E87FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DC43E76-5372-4C7F-A433-0602273E87FC}.Release|Any CPU.Build.0 = Release|Any CPU
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -195,6 +201,7 @@ Global
{A9F81DA3-DA82-423E-A5DD-B11C37548E06} = {96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}
{A0F89B8B-32A3-4C28-8F1B-ADE343F16137} = {73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}
{69A0ACF2-DF1F-4F49-B554-F732DCA938A3} = {73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}
{59889284-FFEE-82E7-94CB-3B43E87DA6CF} = {73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {193AA352-6748-47C1-A5FC-C9AA6B5F000B}
Expand Down
1 change: 1 addition & 0 deletions src/StackExchange.Redis/StackExchange.Redis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="StackExchange.Redis.Benchmarks" />
<InternalsVisibleTo Include="StackExchange.Redis.Server" />
<InternalsVisibleTo Include="StackExchange.Redis.Tests" />
</ItemGroup>
Expand Down
28 changes: 28 additions & 0 deletions tests/StackExchange.Redis.Benchmarks/CustomConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Runtime.InteropServices;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Validators;

namespace StackExchange.Redis.Benchmarks
{
internal class CustomConfig : ManualConfig
{
protected virtual Job Configure(Job j) => j;

public CustomConfig()
{
AddDiagnoser(MemoryDiagnoser.Default);
AddColumn(StatisticColumn.OperationsPerSecond);
AddValidator(JitOptimizationsValidator.FailOnError);

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
AddJob(Configure(Job.Default.WithRuntime(ClrRuntime.Net481)));
}
AddJob(Configure(Job.Default.WithRuntime(CoreRuntime.Core80)));
}
}
}
53 changes: 53 additions & 0 deletions tests/StackExchange.Redis.Benchmarks/FormatBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Net;
using BenchmarkDotNet.Attributes;

namespace StackExchange.Redis.Benchmarks
{
[Config(typeof(CustomConfig))]
public class FormatBenchmarks
{
[GlobalSetup]
public void Setup() { }

[Benchmark]
[Arguments("64")]
[Arguments("-1")]
[Arguments("0")]
[Arguments("123442")]
public long ParseInt64(string s) => Format.ParseInt64(s);

[Benchmark]
[Arguments("64")]
[Arguments("-1")]
[Arguments("0")]
[Arguments("123442")]
public long ParseInt32(string s) => Format.ParseInt32(s);

[Benchmark]
[Arguments("64")]
[Arguments("-1")]
[Arguments("0")]
[Arguments("123442")]
[Arguments("-inf")]
[Arguments("nan")]
public double ParseDouble(string s) => Format.TryParseDouble(s, out var val) ? val : double.NaN;

private byte[] buffer = new byte[128];

[Benchmark]
[Arguments(64D)]
[Arguments(-1D)]
[Arguments(0D)]
[Arguments(123442D)]
[Arguments(double.NegativeInfinity)]
[Arguments(double.NaN)]
public int FormatDouble(double value) => Format.FormatDouble(value, buffer.AsSpan());

[Benchmark]
[Arguments("host.com", -1)]
[Arguments("host.com", 0)]
[Arguments("host.com", 65345)]
public EndPoint ParseEndPoint(string host, int port) => Format.ParseEndPoint(host, port);
}
}
10 changes: 10 additions & 0 deletions tests/StackExchange.Redis.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Reflection;
using BenchmarkDotNet.Running;

namespace StackExchange.Redis.Benchmarks
{
internal static class Program
{
private static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args);
}
}
12 changes: 12 additions & 0 deletions tests/StackExchange.Redis.Benchmarks/SlowConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using BenchmarkDotNet.Jobs;

namespace StackExchange.Redis.Benchmarks
{
internal class SlowConfig : CustomConfig
{
protected override Job Configure(Job j)
=> j.WithLaunchCount(1)
.WithWarmupCount(1)
.WithIterationCount(5);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>StackExchange.Redis MicroBenchmark Suite</Description>
<TargetFrameworks>net481;net8.0</TargetFrameworks>
<Configuration>Release</Configuration>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
</PropertyGroup>

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

<ProjectReference Include="..\..\src\StackExchange.Redis\StackExchange.Redis.csproj" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions tests/StackExchange.Redis.Benchmarks/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet run --framework net8.0 -c Release %*
2 changes: 2 additions & 0 deletions tests/StackExchange.Redis.Benchmarks/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
dotnet run --framework net8.0 -c Release "$@"
Loading