diff --git a/Example.Backend/Example.Backend.csproj b/Example.Backend/Example.Backend.csproj
index 3a78ec5..8a59d29 100644
--- a/Example.Backend/Example.Backend.csproj
+++ b/Example.Backend/Example.Backend.csproj
@@ -14,7 +14,7 @@
TRACE
- x64
+ AnyCPU
diff --git a/Example.Backend/Program.cs b/Example.Backend/Program.cs
index 044f819..4a614c3 100644
--- a/Example.Backend/Program.cs
+++ b/Example.Backend/Program.cs
@@ -40,7 +40,6 @@ class Program
return repo;
}));
-
builder.Services.AddSingleton(p =>
{
var methodRepo = new CollectableMethodRepository();
@@ -48,7 +47,6 @@ class Program
return methodRepo;
});
builder.Services.AddSingleton();
-
builder.Services.AddSingleton();
builder.Services.Configure(o => o.DistributionType = EDistributionType.ExtractorFirst);
diff --git a/Example.Frontend/ClientBasedPrinter.cs b/Example.Frontend/ClientBasedPrinter.cs
index 16ca306..d855364 100644
--- a/Example.Frontend/ClientBasedPrinter.cs
+++ b/Example.Frontend/ClientBasedPrinter.cs
@@ -31,7 +31,7 @@ namespace Example.Frontend
public string GetName()
{
- Console.WriteLine("ClientBasedPrinter called from server!!!!!!!!!!! Vova likes that:)");
+ Console.WriteLine("ClientBasedPrinter called from server!!!!!!!!!!!");
DemoCheck.BackwardCall = true;
return "ClientBasedPrinter from mroa";
diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs
index 4de39e4..5b5f26a 100644
--- a/Example.Frontend/Program.cs
+++ b/Example.Frontend/Program.cs
@@ -16,7 +16,6 @@ using mROA.Implementation;
using mROA.Implementation.Backend;
using mROA.Implementation.Frontend;
-
class Program
{
public static async Task Main(string[] args)
@@ -40,7 +39,7 @@ class Program
builder.Services.AddSingleton();
builder.Services.AddSingleton();
builder.Services.AddSingleton();
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 4567);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 9000);
builder.Services.AddSingleton();
builder.Services.AddOptions();
@@ -95,7 +94,7 @@ class Program
};
Console.WriteLine("Printer created");
- frontendBridge.Obstacle();
+ // frontendBridge.Obstacle();
var name = disposingPrinter.GetName();
DemoCheck.BasicNonParamsCall = true;
Console.WriteLine("Printer name : {0}", name);
@@ -148,13 +147,14 @@ class Program
var token = cts.Token;
var t = Task.Run(async () => await loadSingleton!.AsyncTest(token));
- Thread.Sleep(5000);
+ Console.WriteLine("Waiting for timer");
+ Thread.Sleep(2000);
cts.Cancel();
Console.WriteLine($"Token state {cts.Token.IsCancellationRequested}");
DemoCheck.TaskCancelation = true;
#endif
- const int iterations = 10_000;
+ const int iterations = 5;
var timer = Stopwatch.StartNew();
var x = 0;
for (int i = 0; i < iterations; i++)
diff --git a/Example.Load/Example.Load.csproj b/Example.Load/Example.Load.csproj
index 94ce3a1..e61b5a6 100644
--- a/Example.Load/Example.Load.csproj
+++ b/Example.Load/Example.Load.csproj
@@ -10,7 +10,7 @@
- x64
+ AnyCPU
diff --git a/Example.Load/Program.cs b/Example.Load/Program.cs
index d42cac4..83842c4 100644
--- a/Example.Load/Program.cs
+++ b/Example.Load/Program.cs
@@ -1,4 +1,6 @@
-using System.Net;
+using System.Diagnostics;
+using System.Net;
+using System.Runtime;
using Example.Shared;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -9,14 +11,13 @@ using mROA.Implementation;
using mROA.Implementation.Backend;
using mROA.Implementation.Frontend;
-
const int C = 100;
var time = TimeSpan.FromSeconds(10);
Console.WriteLine($"Starting bench for {time} from {C} connections");
var cts = new CancellationTokenSource();
new RemoteTypeBinder();
var eps = await GetLoadEndpoints(C);
-var tasks = new Task[C];
+var tasks = new Task<(int, double[])>[C];
for (int i = 0; i < C; i++)
{
tasks[i] = Requests(cts.Token, i, eps[i]);
@@ -28,9 +29,17 @@ Console.WriteLine("Start waiting");
await Task.WhenAll(tasks);
Console.WriteLine("End waiting");
-var totalRequests = tasks.Sum(i => i.Result);
+var totalRequests = tasks.Sum(i => i.Result.Item1);
+var totalLatency = tasks.SelectMany(i => i.Result.Item2).ToList();
+totalLatency.Sort();
+var n = totalLatency.Count;
+
+var p50 = totalLatency[(int)(n * 50f / 100f)];
+var p95 = totalLatency[(int)(n * 95f / 100f)];
+var p99 = totalLatency[(int)(n * 99f / 100f)];
Console.WriteLine($"Total requests: {totalRequests:N0}");
Console.WriteLine($"Results: {totalRequests / time.TotalSeconds:N} RPS");
+Console.WriteLine("Latency (µs): p50={0} p95={1} p99={2}", p50, p95, p99);
File.AppendAllText("results.txt", $"[FAST ID] {totalRequests}\r\n");
async Task> GetLoadEndpoints(int count)
@@ -94,10 +103,12 @@ async Task> GetLoadEndpoints(int count)
}
}
-async Task Requests(CancellationToken token, int id, ILoadTest load)
+async Task<(int, double[])> Requests(CancellationToken token, int id, ILoadTest load)
{
try
{
+ var latencyList = new List();
+ var sw = new Stopwatch();
int count = 0;
while (true)
{
@@ -106,11 +117,14 @@ async Task Requests(CancellationToken token, int id, ILoadTest load)
break;
}
+ sw.Restart();
await load.Next(2);
+ sw.Stop();
+ latencyList.Add(sw.Elapsed.TotalMicroseconds);
count++;
}
- return count;
+ return (count, latencyList.ToArray());
}
catch (Exception e)
{
diff --git a/Example.Shared/Example.Shared.csproj b/Example.Shared/Example.Shared.csproj
index 2cb81ef..1cf7822 100644
--- a/Example.Shared/Example.Shared.csproj
+++ b/Example.Shared/Example.Shared.csproj
@@ -10,12 +10,10 @@
-
-
diff --git a/Example.Shared/IPrinter.cs b/Example.Shared/IPrinter.cs
index 5f96cca..e5a5fe3 100644
--- a/Example.Shared/IPrinter.cs
+++ b/Example.Shared/IPrinter.cs
@@ -12,7 +12,8 @@ namespace Example.Shared
{
double Resource { get; set; }
string GetName();
- Task Print(string text, bool someParameter, RequestContext context, CancellationToken cancellationToken);
+ Task Print(string text, bool someParameter,
+ RequestContext context, CancellationToken cancellationToken);
event Action OnPrint;
[Untrusted]
diff --git a/mROA.Cbor/mROA.Cbor.csproj b/mROA.Cbor/mROA.Cbor.csproj
index c08d796..ad210a9 100644
--- a/mROA.Cbor/mROA.Cbor.csproj
+++ b/mROA.Cbor/mROA.Cbor.csproj
@@ -4,7 +4,7 @@
netstandard2.1
enable
true
- 3.0.3
+ 3.0.4
9
mroaLogo.png
true
diff --git a/mROA.sln b/mROA.sln
index 97ede35..9850050 100644
--- a/mROA.sln
+++ b/mROA.sln
@@ -25,10 +25,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.CodegenTools", "mROA.C
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.Load", "Example.Load\Example.Load.csproj", "{930B236B-BDAA-4B8C-8054-5B992BAE6622}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Functionality.Shared", "Functionality.Shared\Functionality.Shared.csproj", "{D9D28596-E10C-4A98-A2AA-573219467506}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{8C20901F-B416-4ABC-8AA4-9059646B081B}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.Benchmark", "mROA.Benchmark\mROA.Benchmark.csproj", "{E021E8B3-56C2-400E-A05E-523CF7831189}"
EndProject
Global
@@ -73,10 +69,6 @@ Global
{930B236B-BDAA-4B8C-8054-5B992BAE6622}.Debug|Any CPU.Build.0 = Debug|Any CPU
{930B236B-BDAA-4B8C-8054-5B992BAE6622}.Release|Any CPU.ActiveCfg = Release|Any CPU
{930B236B-BDAA-4B8C-8054-5B992BAE6622}.Release|Any CPU.Build.0 = Release|Any CPU
- {D9D28596-E10C-4A98-A2AA-573219467506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D9D28596-E10C-4A98-A2AA-573219467506}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D9D28596-E10C-4A98-A2AA-573219467506}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D9D28596-E10C-4A98-A2AA-573219467506}.Release|Any CPU.Build.0 = Release|Any CPU
{E021E8B3-56C2-400E-A05E-523CF7831189}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E021E8B3-56C2-400E-A05E-523CF7831189}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E021E8B3-56C2-400E-A05E-523CF7831189}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -91,7 +83,5 @@ Global
{9BD25A13-3165-47C0-9EAA-5C59EC490E32} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E}
{E7703F5B-F2A6-4A88-AA57-EBB1E38D533E} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E}
{930B236B-BDAA-4B8C-8054-5B992BAE6622} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E}
- {8C20901F-B416-4ABC-8AA4-9059646B081B} = {EAE92F5A-664C-41AB-8811-5885524B5347}
- {D9D28596-E10C-4A98-A2AA-573219467506} = {8C20901F-B416-4ABC-8AA4-9059646B081B}
EndGlobalSection
EndGlobal
diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs
index 5c56d4e..da8b212 100644
--- a/mROA/Implementation/Backend/BasicExecutionModule.cs
+++ b/mROA/Implementation/Backend/BasicExecutionModule.cs
@@ -10,7 +10,6 @@ namespace mROA.Implementation.Backend
private readonly ICancellationRepository _cancellationRepo;
private readonly IMethodRepository _methodRepo;
private readonly IContextualSerializationToolKit _serialization;
-
public BasicExecutionModule(ICancellationRepository cancellationRepo, IMethodRepository methodRepo,
IContextualSerializationToolKit serialization)
{
@@ -18,7 +17,6 @@ namespace mROA.Implementation.Backend
_methodRepo = methodRepo;
_serialization = serialization;
}
-
public ICommandExecution? Execute(CallRequest command, IInstanceRepository instanceRepository,
IRepresentationModule representationModule, IEndPointContext endPointContext)
{
@@ -56,7 +54,6 @@ namespace mROA.Implementation.Backend
};
}
}
-
private ICommandExecution? ExecuteRequest(CallRequest command, IInstanceRepository instanceRepository,
IRepresentationModule representationModule, IEndPointContext endPointContext, IMethodInvoker invoker,
object context, object?[]? castedParams, RequestContext execContext)
@@ -80,7 +77,6 @@ namespace mROA.Implementation.Backend
return result;
}
}
-
private static object GetInstance(CallRequest command, IInstanceRepository instanceRepository,
IMethodInvoker invoker, IEndPointContext endPointContext)
{
@@ -90,7 +86,6 @@ namespace mROA.Implementation.Backend
return context;
}
-
private object?[] CastedParams(CallRequest command, IMethodInvoker invoker, IEndPointContext context)
{
object?[] castedParams = new object[invoker.ParameterTypes.Length];
@@ -101,7 +96,6 @@ namespace mROA.Implementation.Backend
return castedParams;
}
-
public ICommandExecution Cancel(CancelRequest command)
{
var cts = _cancellationRepo.GetCancellation(command.Id);
@@ -115,7 +109,6 @@ namespace mROA.Implementation.Backend
Id = command.Id
};
}
-
private static ICommandExecution? Execute(MethodInvoker invoker, object instance, object?[] parameter,
CallRequest command, RequestContext executionContext)
{
@@ -140,7 +133,6 @@ namespace mROA.Implementation.Backend
Id = command.Id
};
}
-
private ICommandExecution? ExecuteAsync(AsyncMethodInvoker invoker, object instance, object?[]? parameters,
CallRequest command, ICancellationRepository cancellationRepository,
IRepresentationModule representationModule, RequestContext executionContext, IEndPointContext context)
@@ -178,7 +170,6 @@ namespace mROA.Implementation.Backend
return null;
}
-
private ICommandExecution? TypedExecuteAsync(AsyncMethodInvoker invoker, object instance, object?[]? parameters,
CallRequest command, ICancellationRepository cancellationRepository,
IRepresentationModule representationModule, RequestContext executionContext, IEndPointContext context)
diff --git a/mROA/mROA.csproj b/mROA/mROA.csproj
index 75b4830..f0d20b6 100644
--- a/mROA/mROA.csproj
+++ b/mROA/mROA.csproj
@@ -4,7 +4,7 @@
netstandard2.1
enable
mROA
- 3.0.3
+ 3.0.4
YaslePoy
Fast and easy RPC with contex
https://github.com/YaslePoy/mROA