Skip to content

Batch benchmark #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions src/progaudi.tarantool.benchmark/IncrementBatchBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using ProGaudi.Tarantool.Client;
using StackExchange.Redis;

namespace progaudi.tarantool.benchmark
{
[Config(typeof(BenchmarkConfig))]
public class IncrementBatchBenchmark
{
private readonly Box _box;
private readonly IDatabaseAsync _redis;
private readonly int _batchSize;
private readonly ISpace _space;

public IncrementBatchBenchmark()
{
_box = Box.Connect("localhost", 3301).GetAwaiter().GetResult();
_space = _box.Schema["benchmark"];
_redis = ConnectionMultiplexer.Connect("localhost:6379").GetDatabase();
_batchSize = 1000;
}

[Benchmark(Baseline = true)]
public async Task Redis() => await Task.WhenAll(Enumerable.Range(0, _batchSize).Select(_ => _redis.StringIncrementAsync("test_for_benchmarking")).ToArray());

[Benchmark]
public async Task Call() => await Task.WhenAll(Enumerable.Range(0, _batchSize).Select(_ => _box.Call<int>("test_for_benchmarking")).ToArray());

[Benchmark]
public async Task Select() => await Task.WhenAll(Enumerable.Range(0, _batchSize).Select(_ => _space.Select<ValueTuple<int>, (int, int, string, string, string)>(ValueTuple.Create(1))).ToArray());
}
}
2 changes: 1 addition & 1 deletion src/progaudi.tarantool.benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace progaudi.tarantool.benchmark
{
public static class Program
{
public static void Main() => BenchmarkRunner.Run<IncrementBenchmark>();
public static void Main() => BenchmarkRunner.Run<IncrementBatchBenchmark>();
}
}
4 changes: 4 additions & 0 deletions tarantool/testdata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ local function create_spaces_and_indecies()

space3 = box.schema.space.create('with_scalar_index', { if_not_exists = true })
space3:create_index('primary', {type='tree', parts={1, 'scalar'}, if_not_exists = true})

box.schema.space.create('benchmark', { if_not_exists = true })
box.space.benchmark:create_index('primary', {type='hash', parts={1, 'unsigned'}, if_not_exists = true})
box.space.benchmark:insert{1, 2, "sdsdfgasd", "qweqweqweqweqwwe", "asdfasdfasdfasdfasdfasdfsadf"}
end

local function init()
Expand Down