Skip to content

Commit 0fef0cf

Browse files
committed
Tweak stress test
1 parent 60682fa commit 0fef0cf

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Enyim.StressTest/Program.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Foo
2222
class Program
2323
{
2424
private static IMemcachedClient _memcachedClient;
25-
private static int _runTimes = 100000;
25+
private static int _requestTimes = 10000;
2626
private static readonly string _cacheKey = "enyim-stress-test";
2727
private static ILogger _logger;
2828

@@ -39,9 +39,9 @@ static async Task Main(string[] args)
3939

4040
_memcachedClient = host.Services.GetRequiredService<IMemcachedClient>();
4141
_logger = host.Services.GetRequiredService<ILogger<Program>>();
42-
var runTimes = host.Services.GetRequiredService<IConfiguration>().GetValue<int?>("RunTimes");
43-
_runTimes = runTimes.HasValue ? runTimes.Value : _runTimes;
44-
42+
var requestTimes = host.Services.GetRequiredService<IConfiguration>().GetValue<int?>("requestTimes");
43+
_requestTimes = requestTimes.HasValue ? requestTimes.Value : _requestTimes;
44+
Console.WriteLine($"Request Times: {_requestTimes}");
4545
await Run();
4646
}
4747

@@ -54,7 +54,6 @@ static async Task TrySingle()
5454

5555
static async Task RunSync(int cnt)
5656
{
57-
Console.WriteLine("Use Get");
5857
await TrySingle();
5958
var sw = Stopwatch.StartNew();
6059
var errCnt = 0;
@@ -80,14 +79,14 @@ static async Task RunSync(int cnt)
8079

8180
Thread.Sleep(TimeSpan.FromSeconds(3));
8281
await TrySingle();
82+
Console.WriteLine("Use Get");
8383
Console.WriteLine($"Time: {sw.ElapsedMilliseconds}ms");
84-
Console.WriteLine($"Error Cnt: {errCnt}");
84+
Console.WriteLine($"Failures: {errCnt}");
8585
Console.WriteLine($"Avg: {Convert.ToDouble(sw.ElapsedMilliseconds) / Convert.ToDouble(cnt)}ms");
8686
}
8787

8888
static async Task RunAsync(int cnt)
8989
{
90-
Console.WriteLine("Use GetValueAsync");
9190
await TrySingle();
9291
var sw = Stopwatch.StartNew();
9392
var obj = new object();
@@ -114,14 +113,15 @@ static async Task RunAsync(int cnt)
114113
sw.Stop();
115114
Thread.Sleep(TimeSpan.FromSeconds(3));
116115
await TrySingle();
116+
Console.WriteLine("Use GetValueAsync");
117117
Console.WriteLine($"Time: {sw.ElapsedMilliseconds}ms");
118-
Console.WriteLine($"Error Cnt: {errCnt}");
118+
Console.WriteLine($"Failures: {errCnt}");
119119
Console.WriteLine($"Avg: {Convert.ToDouble(sw.ElapsedMilliseconds) / Convert.ToDouble(cnt)}ms");
120120
}
121121

122122
static async Task Run()
123123
{
124-
var cnt = _runTimes;
124+
var cnt = _requestTimes;
125125
await RunAsync(cnt);
126126
//await RunSync(cnt);
127127
}

0 commit comments

Comments
 (0)