3
3
using System . Collections . Concurrent ;
4
4
using System . Diagnostics ;
5
5
using System . Text . Json ;
6
-
7
6
using CommandLine ;
8
-
9
- using Glide ;
10
-
11
7
using LinqStatistics ;
12
-
13
8
using StackExchange . Redis ;
9
+ using Valkey . Glide ;
10
+
11
+ namespace csharp_benchmark ;
14
12
15
13
public static class MainClass
16
14
{
@@ -164,12 +162,12 @@ private static Dictionary<string, object> LatencyResults(
164
162
ConcurrentBag < double > latencies
165
163
) => new ( )
166
164
{
167
- { prefix + "_p50_latency" , CalculateLatency ( latencies , 0.5 ) } ,
168
- { prefix + "_p90_latency" , CalculateLatency ( latencies , 0.9 ) } ,
169
- { prefix + "_p99_latency" , CalculateLatency ( latencies , 0.99 ) } ,
170
- { prefix + "_average_latency" , Math . Round ( latencies . Average ( ) , 3 ) } ,
171
- { prefix + "_std_dev" , latencies . StandardDeviation ( ) } ,
172
- } ;
165
+ { prefix + "_p50_latency" , CalculateLatency ( latencies , 0.5 ) } ,
166
+ { prefix + "_p90_latency" , CalculateLatency ( latencies , 0.9 ) } ,
167
+ { prefix + "_p99_latency" , CalculateLatency ( latencies , 0.99 ) } ,
168
+ { prefix + "_average_latency" , Math . Round ( latencies . Average ( ) , 3 ) } ,
169
+ { prefix + "_std_dev" , latencies . StandardDeviation ( ) } ,
170
+ } ;
173
171
174
172
private static async Task RunClients (
175
173
ClientWrapper [ ] clients ,
@@ -240,8 +238,8 @@ internal ClientWrapper(Func<string, Task<string?>> get, Func<string, string, Tas
240
238
241
239
private static async Task < ClientWrapper [ ] > CreateClients ( int clientCount ,
242
240
Func < Task < ( Func < string , Task < string ? > > ,
243
- Func < string , string , Task > ,
244
- Action ) > > clientCreation )
241
+ Func < string , string , Task > ,
242
+ Action ) > > clientCreation )
245
243
{
246
244
IEnumerable < Task < ClientWrapper > > tasks = Enumerable . Range ( 0 , clientCount ) . Select ( async ( _ ) =>
247
245
{
@@ -266,8 +264,8 @@ private static async Task RunWithParameters(int total_commands,
266
264
BaseClient glide_client = new GlideClient ( host , PORT , useTLS ) ;
267
265
return Task . FromResult < ( Func < string , Task < string ? > > , Func < string , string , Task > , Action ) > (
268
266
( async ( key ) => await glide_client . Get ( key ) ,
269
- async ( key , value ) => await glide_client . Set ( key , value ) ,
270
- ( ) => glide_client . Dispose ( ) ) ) ;
267
+ async ( key , value ) => await glide_client . Set ( key , value ) ,
268
+ ( ) => glide_client . Dispose ( ) ) ) ;
271
269
} ) ;
272
270
273
271
await RunClients (
@@ -282,14 +280,14 @@ await RunClients(
282
280
if ( clientsToRun == "all" )
283
281
{
284
282
ClientWrapper [ ] clients = await CreateClients ( clientCount , ( ) =>
285
- {
286
- ConnectionMultiplexer connection = ConnectionMultiplexer . Connect ( GetAddressForStackExchangeRedis ( host , useTLS ) ) ;
287
- IDatabase db = connection . GetDatabase ( ) ;
288
- return Task . FromResult < ( Func < string , Task < string ? > > , Func < string , string , Task > , Action ) > (
289
- ( async ( key ) => await db . StringGetAsync ( key ) ,
290
- async ( key , value ) => await db . StringSetAsync ( key , value ) ,
291
- ( ) => connection . Dispose ( ) ) ) ;
292
- } ) ;
283
+ {
284
+ ConnectionMultiplexer connection = ConnectionMultiplexer . Connect ( GetAddressForStackExchangeRedis ( host , useTLS ) ) ;
285
+ IDatabase db = connection . GetDatabase ( ) ;
286
+ return Task . FromResult < ( Func < string , Task < string ? > > , Func < string , string , Task > , Action ) > (
287
+ ( async ( key ) => await db . StringGetAsync ( key ) ,
288
+ async ( key , value ) => await db . StringSetAsync ( key , value ) ,
289
+ ( ) => connection . Dispose ( ) ) ) ;
290
+ } ) ;
293
291
await RunClients (
294
292
clients ,
295
293
"StackExchange.Redis" ,
@@ -324,4 +322,4 @@ public static async Task Main(string[] args)
324
322
325
323
PrintResults ( options . ResultsFile ) ;
326
324
}
327
- }
325
+ }
0 commit comments