diff --git a/.github/workflows/csharp-benchmark.yml b/.github/workflows/csharp-benchmark.yml new file mode 100644 index 0000000000..192ed0298a --- /dev/null +++ b/.github/workflows/csharp-benchmark.yml @@ -0,0 +1,65 @@ +name: C# client benchmarks + +on: + workflow_dispatch: + inputs: + name: + required: false + type: string + run-glide-only: + description: "flag that tells the Benchmark to measure only GLIDE client" + required: false + default: true + type: boolean + +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 + dotnet: + - 6.0 + - 8.0 + 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/setup-protoc@v2.1.0 + with: + version: "25.1" + + - name: Set up dotnet ${{ matrix.dotnet }} + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ matrix.dotnet }} + + - name: benchmark + uses: ./.github/workflows/test-benchmark + with: + language-flag: -csharp + run-glide-only: ${{ inputs.run-glide-only }} + + - name: Upload test reports + if: always() + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: test-reports-redis-${{ matrix.redis }}-dotnet-${{ matrix.dotnet }} + path: | + benchmarks/results/** diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 3c838c38c5..cce9419d9d 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -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 @@ -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 diff --git a/.github/workflows/test-benchmark/action.yml b/.github/workflows/test-benchmark/action.yml index 91cc36697f..c0fb3f322c 100644 --- a/.github/workflows/test-benchmark/action.yml +++ b/.github/workflows/test-benchmark/action.yml @@ -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" @@ -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 }} diff --git a/benchmarks/csharp/Program.cs b/benchmarks/csharp/Program.cs index 11df0e36be..e4a1615965 100644 --- a/benchmarks/csharp/Program.cs +++ b/benchmarks/csharp/Program.cs @@ -6,6 +6,8 @@ using System.Diagnostics; using System.Text.Json; +using BeetleX.Redis; + using CommandLine; using Glide; @@ -14,6 +16,8 @@ using StackExchange.Redis; +using FreeRedisClient = FreeRedis.RedisClient; + public static class MainClass { private enum ChosenAction { GET_NON_EXISTING, GET_EXISTING, SET }; @@ -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)); @@ -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>, Func, Action)>( + (async (key) => await DB.Get(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>, Func, 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 + ); } } diff --git a/benchmarks/csharp/csharp_benchmark.csproj b/benchmarks/csharp/csharp_benchmark.csproj index de05de0d82..efebe25ab4 100644 --- a/benchmarks/csharp/csharp_benchmark.csproj +++ b/benchmarks/csharp/csharp_benchmark.csproj @@ -5,9 +5,11 @@ + + - + diff --git a/csharp/lib/glide.csproj b/csharp/lib/glide.csproj index b890217632..519ec02cad 100644 --- a/csharp/lib/glide.csproj +++ b/csharp/lib/glide.csproj @@ -8,7 +8,7 @@ - +