2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-06-13 22:48:42 +00:00
This commit is contained in:
2026-06-09 01:40:29 +03:00
parent 2bdd5d5022
commit a741013621
19 changed files with 887 additions and 185 deletions
+11 -8
View File
@@ -15,7 +15,10 @@ public class JsonTest
public static async Task<TestResults> DoTest(string address,
Dictionary<string, BusinessDocument[]> docsWorkloads,
Dictionary<string, byte[]> dataWorkloads,
Dictionary<string, int[]> intWorkloads)
Dictionary<string, int[]> intWorkloads,
int warmupDelayMs = 3000,
int postHandshakeDelayMs = 2000,
int sampleDelayMs = 3000)
{
var rt = new TestResults();
@@ -28,20 +31,20 @@ public class JsonTest
using var http = new HttpClient { BaseAddress = new Uri(address) };
Thread.Sleep(3000);
Thread.Sleep(warmupDelayMs);
var (tx, rx, ctx, crx) = mon.GetDiff(0, 0);
Console.WriteLine($"Handshake {ctx}/{crx}");
await Task.Delay(2000);
await Task.Delay(postHandshakeDelayMs);
foreach (var w in docsWorkloads)
{
Console.Write("Workload: " + w.Key);
var docs = await JsonRpcCallAsync(http, "EchoDocuments", w.Value);
await Task.Delay(3000);
await Task.Delay(sampleDelayMs);
(tx, rx, ctx, crx) = mon.GetDiff(tx, rx);
Console.WriteLine($", {tx}/{rx}, {ctx}/{crx}");
@@ -62,7 +65,7 @@ public class JsonTest
// throw new Exception("No match");
await Task.Delay(3000);
await Task.Delay(sampleDelayMs);
(tx, rx, ctx, crx) = mon.GetDiff(tx, rx);
Console.WriteLine($", {tx}/{rx}, {ctx}/{crx}");
//Console.WriteLine($"Socket {sock.BytesSent}/{sock.BytesReceived}");
@@ -82,7 +85,7 @@ public class JsonTest
// throw new Exception("No match");
await Task.Delay(3000);
await Task.Delay(sampleDelayMs);
(tx, rx, ctx, crx) = mon.GetDiff(tx, rx);
Console.WriteLine($", {tx}/{rx}, {ctx}/{crx}");
//Console.WriteLine($"Socket {sock.BytesSent}/{sock.BytesReceived}");
@@ -91,7 +94,7 @@ public class JsonTest
}
await Task.Delay(3000);
await Task.Delay(sampleDelayMs);
(tx, rx) = mon.GetTotals();
Console.WriteLine($"Transfer {tx}/{rx}");
@@ -125,4 +128,4 @@ public class JsonTest
using var doc = JsonDocument.Parse(raw);
return (doc.RootElement.Clone(), raw);
}
}
}