Skip to content
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

C#: benchmark GLIDER vs other clients #85

Merged
Show file tree
Hide file tree
Changes from 2 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
59 changes: 59 additions & 0 deletions .github/workflows/csharp-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: C# client benchmarks

on:
workflow_dispatch:
inputs:
name:
required: false
type: string
# TODO: remove this
push:

run-name: ${{ inputs.name == '' && format('{0} @ {1}', github.ref_name, github.sha) || inputs.name }}

jobs:
csharp-benchmark:
timeout-minutes: 25
strategy:
# Run all jobs
fail-fast: false
matrix:
redis:
- 6.2.14
- 7.2.3
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install redis
uses: ./.github/workflows/install-redis
with:
redis-version: ${{ matrix.redis }}

- name: Install protoc (protobuf)
uses: arduino/[email protected]
with:
version: "25.1"

- name: Set up dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

- name: benchmark
uses: ./.github/workflows/test-benchmark
with:
language-flag: -csharp
run-glide-only: false # TODO - delete this line

- name: Upload test reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.redis }}
path: |
benchmarks/results/**
6 changes: 1 addition & 5 deletions .github/workflows/csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
version: "25.1"

- name: Set up dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

Expand All @@ -60,10 +60,6 @@ jobs:
working-directory: ./csharp
run: dotnet test --framework net6.0 /warnaserror

- uses: ./.github/workflows/test-benchmark
with:
language-flag: -csharp

lint-rust:
timeout-minutes: 10
runs-on: ubuntu-latest
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test-benchmark/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ inputs:
description: "flag that tells the benchmark to run a certain language"
required: true
type: string
run-glide-only:
description: "flag that tells the Benchmark to measure only GLIDE client"
required: false
default: true
type: boolean

runs:
using: "composite"
Expand All @@ -15,4 +20,4 @@ runs:

- shell: bash
working-directory: ./benchmarks
run: ./install_and_test.sh -no-tls -minimal -only-glide -data 1 -tasks 10 ${{ inputs.language-flag }}
run: ./install_and_test.sh -no-tls -minimal ${{ inputs.run-glide-only == 'true' && '-only-glide' || '' }} -data 1 -tasks 10 ${{ inputs.language-flag }}
46 changes: 46 additions & 0 deletions benchmarks/csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Diagnostics;
using System.Text.Json;

using BeetleX.Redis;

using CommandLine;

using Glide;
Expand All @@ -14,6 +16,8 @@

using StackExchange.Redis;

using FreeRedisClient = FreeRedis.RedisClient;

public static class MainClass
{
private enum ChosenAction { GET_NON_EXISTING, GET_EXISTING, SET };
Expand Down Expand Up @@ -310,6 +314,7 @@ await run_clients(

if (clientsToRun == "all")
{
// https://github.com/StackExchange/StackExchange.Redis
var clients = await createClients(clientCount, () =>
{
var connection = ConnectionMultiplexer.Connect(getAddressForStackExchangeRedis(host, useTLS));
Expand All @@ -331,6 +336,47 @@ await run_clients(
{
client.Dispose();
}

// https://github.com/beetlex-io/BeetleX.Redis
clients = await createClients(clientCount, () =>
{
var DB = new RedisDB();
DB.Host.AddWriteHost(host, PORT, useTLS);
return Task.FromResult<(Func<string, Task<string?>>, Func<string, string, Task>, Action)>(
(async (key) => await DB.Get<string>(key),
async (key, value) => await DB.Set(key, value),
() => { }
));
});
await run_clients(
clients,
"BeetleX.Redis",
total_commands,
data_size,
num_of_concurrent_tasks
);

// https://github.com/2881099/FreeRedis
clients = await createClients(clientCount, () =>
{
var config = new FreeRedis.ConnectionStringBuilder();
config.Host = $"{host}:{PORT}";
config.Ssl = useTLS;
var client = new FreeRedisClient(config);

return Task.FromResult<(Func<string, Task<string?>>, Func<string, string, Task>, Action)>(
(async (key) => await client.GetAsync(key),
async (key, value) => await client.SetAsync(key, value),
() => client.Dispose()
));
});
await run_clients(
clients,
"FreeRedis",
total_commands,
data_size,
num_of_concurrent_tasks
);
}
}

Expand Down
4 changes: 3 additions & 1 deletion benchmarks/csharp/csharp_benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BeetleX.Redis" Version="1.4.9.1803" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="FreeRedis" Version="1.2.13" />
<PackageReference Include="LinqStatistics" Version="2.3.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.48" />
<PackageReference Include="StackExchange.Redis" Version="2.7.17" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion csharp/lib/glide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="cargo build --release" />
<Exec Command="cargo build --release" EnvironmentVariables="CARGO_TERM_COLOR=always" />
</Target>

<ItemGroup>
Expand Down
Loading