-
-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Benchmark ServerStreaming Scenario
- Loading branch information
1 parent
ca024f9
commit 94d34e1
Showing
6 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
perf/BenchmarkApp/PerformanceTest.Client/ServerStreamingScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Grpc.Net.Client; | ||
using MagicOnion.Client; | ||
using PerformanceTest.Shared; | ||
|
||
namespace PerformanceTest.Client; | ||
|
||
public class ServerStreamingScenario : IScenario | ||
{ | ||
IPerfTestService client = default!; | ||
readonly TimeProvider timeProvider = TimeProvider.System; | ||
|
||
public ValueTask PrepareAsync(GrpcChannel channel) | ||
{ | ||
this.client = MagicOnionClient.Create<IPerfTestService>(channel); | ||
return ValueTask.CompletedTask; | ||
} | ||
|
||
public async ValueTask RunAsync(int connectionId, PerformanceTestRunningContext ctx, CancellationToken cancellationToken) | ||
{ | ||
var stream = await client.ServerStreamingAsync(); | ||
while(!cancellationToken.IsCancellationRequested) | ||
{ | ||
ctx.Increment(); | ||
var begin = timeProvider.GetTimestamp(); | ||
//_ = stream.ResponseStream.Current; | ||
await stream.ResponseStream.MoveNext(cancellationToken); | ||
ctx.Latency(connectionId, timeProvider.GetElapsedTime(begin)); | ||
} | ||
} | ||
|
||
public Task CompleteAsync() | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
using MagicOnion; | ||
using MessagePack; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime; | ||
using MemoryPack; | ||
|
||
namespace PerformanceTest.Shared; | ||
|
||
public interface IPerfTestService : IService<IPerfTestService> | ||
{ | ||
// Unary | ||
UnaryResult<Nil> UnaryParameterless(); | ||
UnaryResult<string> UnaryArgRefReturnRef(string arg1, int arg2, int arg3); | ||
UnaryResult<string> UnaryArgDynamicArgumentTupleReturnRef(string arg1, int arg2, int arg3, int arg4); | ||
UnaryResult<int> UnaryArgDynamicArgumentTupleReturnValue(string arg1, int arg2, int arg3, int arg4); | ||
UnaryResult<(int StatusCode, byte[] Data)> UnaryLargePayloadAsync(string arg1, int arg2, int arg3, int arg4, byte[] arg5); | ||
UnaryResult<ComplexResponse> UnaryComplexAsync(string arg1, int arg2, int arg3, int arg4); | ||
|
||
// ServerStreaming | ||
Task<ServerStreamingResult<SimpleResponse>> ServerStreamingAsync(); | ||
} |