mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-04-29 06:48:41 +00:00
Merge branch 'main' of https://github.com/esiur/esiur-dotnet
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Tests.Queueing.Client
|
||||
{
|
||||
public static class EvalPrinter
|
||||
{
|
||||
public static void Print(EsiurQueueEval.EvalResult r)
|
||||
{
|
||||
Console.WriteLine("=== Evaluation Result ===");
|
||||
Console.WriteLine($"α (HasResource probability): {r.Alpha:F3}");
|
||||
Console.WriteLine($"λ̂ (effective arrival rate): {r.LambdaEventsPerSecond:F2} events/s");
|
||||
Console.WriteLine();
|
||||
|
||||
PrintLatencyTable(r.Latency);
|
||||
|
||||
Console.WriteLine();
|
||||
PrintValidation(r.Validation);
|
||||
|
||||
if (r.FlushSizeStats != null)
|
||||
{
|
||||
Console.WriteLine();
|
||||
PrintStats("Flush size (≤ window)", r.FlushSizeStats);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintLatencyTable(EsiurQueueEval.LatencyDecomposition l)
|
||||
{
|
||||
Console.WriteLine("Latency Decomposition (ms)");
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
Console.WriteLine($"{"Metric",-16} {"Mean",8} {"P50",8} {"P95",8} {"P99",8} {"Max",8}");
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
|
||||
PrintRow("Readiness R", l.ReadinessMs);
|
||||
PrintRow("HOL Δ", l.HolMs);
|
||||
PrintRow("End-to-End D", l.EndToEndMs);
|
||||
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
}
|
||||
|
||||
private static void PrintValidation(EsiurQueueEval.ModelValidation v)
|
||||
{
|
||||
Console.WriteLine("Resequencing Model Validation");
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
Console.WriteLine("Absolute error |d − d̂| (ms)");
|
||||
PrintStats("Error", v.AbsErrorMs);
|
||||
|
||||
if (v.MaxNegativeSlackMs > 0)
|
||||
{
|
||||
Console.WriteLine($"Max negative slack (delivered earlier than model): {v.MaxNegativeSlackMs:F4} ms");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("No negative slack observed (model is conservative).");
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintRow(string name, EsiurQueueEval.Stats s)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"{name,-16} " +
|
||||
$"{s.Mean,8:F2} " +
|
||||
$"{s.P50,8:F2} " +
|
||||
$"{s.P95,8:F2} " +
|
||||
$"{s.P99,8:F2} " +
|
||||
$"{s.Max,8:F2}"
|
||||
);
|
||||
}
|
||||
|
||||
private static void PrintStats(string name, EsiurQueueEval.Stats s)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"{name,-20} " +
|
||||
$"mean={s.Mean,8:F02} " +
|
||||
$"p50={s.P50,8:F02} " +
|
||||
$"p95={s.P95,8:F02} " +
|
||||
$"p99={s.P99,8:F02} " +
|
||||
$"max={s.Max,8:F02}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ Console.WriteLine($"[Client-T2] Connecting to {host}:{port}, trials={trials}");
|
||||
var wh = new Warehouse();
|
||||
|
||||
var serviceResource = await wh.Get<EpResource>(
|
||||
$"ep://{host}:{port}/queueing");
|
||||
$"ep://{host}:{port}/sys/queueing");
|
||||
|
||||
var service = (dynamic)serviceResource;
|
||||
|
||||
@@ -43,10 +43,11 @@ serviceResource.PropertyChanged += Service_PropertyChanged;
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("Starting next test: Delay=" + delays[currentDelay] + " Alpha=" + alphas[currentAlpha]);
|
||||
Console.WriteLine("Starting test: Delay=" + delays[currentDelay] + " Alpha=" + alphas[currentAlpha]);
|
||||
|
||||
service.StartUpdatesLocal(delays[currentDelay], trials, alphas[currentAlpha]);
|
||||
|
||||
await Task.Delay(-1);
|
||||
|
||||
|
||||
void Service_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
@@ -61,7 +62,7 @@ void Service_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
Console.WriteLine(result);
|
||||
counter = 0;
|
||||
|
||||
if (currentAlpha == delays.Length - 1)
|
||||
if (currentAlpha == alphas.Length - 1)
|
||||
{
|
||||
currentAlpha = 0;
|
||||
currentDelay++;
|
||||
|
||||
@@ -7,84 +7,6 @@ namespace Esiur.Tests.Queueing.Client
|
||||
{
|
||||
public static class EsiurQueueEval
|
||||
{
|
||||
|
||||
public static class EvalPrinter
|
||||
{
|
||||
public static void Print(EsiurQueueEval.EvalResult r)
|
||||
{
|
||||
Console.WriteLine("=== Evaluation Result ===");
|
||||
Console.WriteLine($"α (HasResource probability): {r.Alpha:F3}");
|
||||
Console.WriteLine($"λ̂ (effective arrival rate): {r.LambdaEventsPerSecond:F2} events/s");
|
||||
Console.WriteLine();
|
||||
|
||||
PrintLatencyTable(r.Latency);
|
||||
|
||||
Console.WriteLine();
|
||||
PrintValidation(r.Validation);
|
||||
|
||||
if (r.FlushSizeStats != null)
|
||||
{
|
||||
Console.WriteLine();
|
||||
PrintStats("Flush size (≤ window)", r.FlushSizeStats);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintLatencyTable(EsiurQueueEval.LatencyDecomposition l)
|
||||
{
|
||||
Console.WriteLine("Latency Decomposition (ms)");
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
Console.WriteLine($"{"Metric",-16} {"Mean",8} {"P50",8} {"P95",8} {"P99",8} {"Max",8}");
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
|
||||
PrintRow("Readiness R", l.ReadinessMs);
|
||||
PrintRow("HOL Δ", l.HolMs);
|
||||
PrintRow("End-to-End D", l.EndToEndMs);
|
||||
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
}
|
||||
|
||||
private static void PrintValidation(EsiurQueueEval.ModelValidation v)
|
||||
{
|
||||
Console.WriteLine("Resequencing Model Validation");
|
||||
Console.WriteLine("-----------------------------------------------");
|
||||
Console.WriteLine("Absolute error |d − d̂| (ms)");
|
||||
PrintStats("Error", v.AbsErrorMs);
|
||||
|
||||
if (v.MaxNegativeSlackMs > 0)
|
||||
{
|
||||
Console.WriteLine($"Max negative slack (delivered earlier than model): {v.MaxNegativeSlackMs:F4} ms");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("No negative slack observed (model is conservative).");
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintRow(string name, EsiurQueueEval.Stats s)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"{name,-16} " +
|
||||
$"{s.Mean,8:F2} " +
|
||||
$"{s.P50,8:F2} " +
|
||||
$"{s.P95,8:F2} " +
|
||||
$"{s.P99,8:F2} " +
|
||||
$"{s.Max,8:F2}"
|
||||
);
|
||||
}
|
||||
|
||||
private static void PrintStats(string name, EsiurQueueEval.Stats s)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"{name,-20} " +
|
||||
$"mean={s.Mean,8:F02} " +
|
||||
$"p50={s.P50,8:F02} " +
|
||||
$"p95={s.P95,8:F02} " +
|
||||
$"p99={s.P99,8:F02} " +
|
||||
$"max={s.Max,8:F02}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record Stats(double Mean, double P50, double P95, double P99, double Max);
|
||||
|
||||
public sealed record LatencyDecomposition(Stats ReadinessMs, Stats HolMs, Stats EndToEndMs);
|
||||
@@ -345,5 +267,4 @@ namespace Esiur.Tests.Queueing.Client
|
||||
Max: arr.Average(s => s.Max));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user