diff --git a/StackExchange.Redis.sln b/StackExchange.Redis.sln
index 20b5e2f01..8f772ae42 100644
--- a/StackExchange.Redis.sln
+++ b/StackExchange.Redis.sln
@@ -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}"
@@ -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
@@ -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
@@ -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}
diff --git a/src/StackExchange.Redis/StackExchange.Redis.csproj b/src/StackExchange.Redis/StackExchange.Redis.csproj
index e1b428a36..44efe09be 100644
--- a/src/StackExchange.Redis/StackExchange.Redis.csproj
+++ b/src/StackExchange.Redis/StackExchange.Redis.csproj
@@ -43,6 +43,7 @@
+
diff --git a/tests/StackExchange.Redis.Benchmarks/CustomConfig.cs b/tests/StackExchange.Redis.Benchmarks/CustomConfig.cs
new file mode 100644
index 000000000..09f44cc31
--- /dev/null
+++ b/tests/StackExchange.Redis.Benchmarks/CustomConfig.cs
@@ -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)));
+ }
+ }
+}
diff --git a/tests/StackExchange.Redis.Benchmarks/FormatBenchmarks.cs b/tests/StackExchange.Redis.Benchmarks/FormatBenchmarks.cs
new file mode 100644
index 000000000..77548b254
--- /dev/null
+++ b/tests/StackExchange.Redis.Benchmarks/FormatBenchmarks.cs
@@ -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);
+ }
+}
diff --git a/tests/StackExchange.Redis.Benchmarks/Program.cs b/tests/StackExchange.Redis.Benchmarks/Program.cs
new file mode 100644
index 000000000..622d7d593
--- /dev/null
+++ b/tests/StackExchange.Redis.Benchmarks/Program.cs
@@ -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);
+ }
+}
diff --git a/tests/StackExchange.Redis.Benchmarks/SlowConfig.cs b/tests/StackExchange.Redis.Benchmarks/SlowConfig.cs
new file mode 100644
index 000000000..0c3546006
--- /dev/null
+++ b/tests/StackExchange.Redis.Benchmarks/SlowConfig.cs
@@ -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);
+ }
+}
diff --git a/tests/StackExchange.Redis.Benchmarks/StackExchange.Redis.Benchmarks.csproj b/tests/StackExchange.Redis.Benchmarks/StackExchange.Redis.Benchmarks.csproj
new file mode 100644
index 000000000..be9a3081b
--- /dev/null
+++ b/tests/StackExchange.Redis.Benchmarks/StackExchange.Redis.Benchmarks.csproj
@@ -0,0 +1,15 @@
+
+
+ StackExchange.Redis MicroBenchmark Suite
+ net481;net8.0
+ Release
+ Exe
+ true
+
+
+
+
+
+
+
+
diff --git a/tests/StackExchange.Redis.Benchmarks/run.cmd b/tests/StackExchange.Redis.Benchmarks/run.cmd
new file mode 100644
index 000000000..2b8844c56
--- /dev/null
+++ b/tests/StackExchange.Redis.Benchmarks/run.cmd
@@ -0,0 +1 @@
+dotnet run --framework net8.0 -c Release %*
\ No newline at end of file
diff --git a/tests/StackExchange.Redis.Benchmarks/run.sh b/tests/StackExchange.Redis.Benchmarks/run.sh
new file mode 100755
index 000000000..1824c7161
--- /dev/null
+++ b/tests/StackExchange.Redis.Benchmarks/run.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+dotnet run --framework net8.0 -c Release "$@"
\ No newline at end of file