Skip to content

Commit 9edffca

Browse files
committed
Add simple benchmarking
1 parent 2799290 commit 9edffca

File tree

6 files changed

+113
-1
lines changed

6 files changed

+113
-1
lines changed

progaudi.tarantool.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
global.json = global.json
1313
EndProjectSection
1414
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "progaudi.tarantool.benchmark", "src\progaudi.tarantool.benchmark\progaudi.tarantool.benchmark.csproj", "{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}"
16+
EndProject
1517
Global
1618
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1719
Debug|Any CPU = Debug|Any CPU
@@ -46,6 +48,18 @@ Global
4648
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x64.Build.0 = Release|Any CPU
4749
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x86.ActiveCfg = Release|Any CPU
4850
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x86.Build.0 = Release|Any CPU
51+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
53+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x64.ActiveCfg = Debug|Any CPU
54+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x64.Build.0 = Debug|Any CPU
55+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x86.ActiveCfg = Debug|Any CPU
56+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x86.Build.0 = Debug|Any CPU
57+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
58+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|Any CPU.Build.0 = Release|Any CPU
59+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x64.ActiveCfg = Release|Any CPU
60+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x64.Build.0 = Release|Any CPU
61+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x86.ActiveCfg = Release|Any CPU
62+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x86.Build.0 = Release|Any CPU
4963
EndGlobalSection
5064
GlobalSection(SolutionProperties) = preSolution
5165
HideSolutionNode = FALSE
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using BenchmarkDotNet.Columns;
2+
using BenchmarkDotNet.Configs;
3+
using BenchmarkDotNet.Diagnosers;
4+
using BenchmarkDotNet.Environments;
5+
using BenchmarkDotNet.Exporters;
6+
using BenchmarkDotNet.Exporters.Csv;
7+
using BenchmarkDotNet.Jobs;
8+
using BenchmarkDotNet.Toolchains.CsProj;
9+
10+
namespace progaudi.tarantool.benchmark
11+
{
12+
internal class BenchmarkConfig : ManualConfig
13+
{
14+
public BenchmarkConfig()
15+
{
16+
Add(StatisticColumn.P95);
17+
18+
Add(MemoryDiagnoser.Default);
19+
20+
// https://github.com/dotnet/BenchmarkDotNet/issues/500
21+
//Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X86).With(Runtime.Clr));
22+
//Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X64).With(Runtime.Clr));
23+
24+
//Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Clr));
25+
26+
// RyuJit for .NET Core 1.1
27+
Add(Job.Default.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp11).WithId("netcore1.1"));
28+
29+
// RyuJit for .NET Core 2.0
30+
Add(Job.Default.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20).WithId("netcore2.0"));
31+
32+
Add(MarkdownExporter.GitHub);
33+
Add(CsvMeasurementsExporter.Default);
34+
}
35+
}
36+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Threading.Tasks;
2+
using BenchmarkDotNet.Attributes;
3+
using ProGaudi.Tarantool.Client;
4+
using ProGaudi.Tarantool.Client.Model.Responses;
5+
using StackExchange.Redis;
6+
7+
namespace progaudi.tarantool.benchmark
8+
{
9+
[Config(typeof(BenchmarkConfig))]
10+
public class IncrementBenchmark
11+
{
12+
private readonly Box _box;
13+
private readonly IDatabaseAsync _redis;
14+
15+
public IncrementBenchmark()
16+
{
17+
_box = Box.Connect("localhost", 3301).GetAwaiter().GetResult();
18+
_redis = ConnectionMultiplexer.Connect("localhost:6379").GetDatabase();
19+
}
20+
21+
[Benchmark(Baseline = true)]
22+
public async Task<long> Redis() => await _redis.StringIncrementAsync("test_for_benchmarking");
23+
24+
[Benchmark]
25+
public async Task<DataResponse<int[]>> Tarantool() => await _box.Call<int>("test_for_benchmarking");
26+
}
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using BenchmarkDotNet.Running;
2+
3+
namespace progaudi.tarantool.benchmark
4+
{
5+
public static class Program
6+
{
7+
public static void Main() => BenchmarkRunner.Run<IncrementBenchmark>();
8+
}
9+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
6+
<WarningsAsErrors>true</WarningsAsErrors>
7+
8+
<AssemblyName>progaudi.tarantool.benchmark</AssemblyName>
9+
<RootNamespace>ProGaudi.Tarantool.Benchmark</RootNamespace>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="BenchmarkDotNet" Version="0.10.9" />
14+
<PackageReference Include="StackExchange.Redis" Version="1.2.6" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\progaudi.tarantool\progaudi.tarantool.csproj" />
19+
</ItemGroup>
20+
</Project>

tarantool/testdata.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,10 @@ function clear_data(spaceNames)
110110
for _, spaceName in ipairs(spaceNames) do
111111
truncate_space(spaceName)
112112
end
113-
end
113+
end
114+
115+
local test_int = 0
116+
function test_for_benchmarking()
117+
test_int = test_int + 1
118+
return test_int
119+
end

0 commit comments

Comments
 (0)