Refactoring
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
|
||||
@@ -40,7 +40,6 @@ class Program
|
||||
|
||||
return repo;
|
||||
}));
|
||||
|
||||
builder.Services.AddSingleton<IMethodRepository>(p =>
|
||||
{
|
||||
var methodRepo = new CollectableMethodRepository();
|
||||
@@ -48,7 +47,6 @@ class Program
|
||||
return methodRepo;
|
||||
});
|
||||
builder.Services.AddSingleton<ICallIndexProvider, GeneratedCallIndexProvider>();
|
||||
|
||||
builder.Services.AddSingleton<ICancellationRepository, CancellationRepository>();
|
||||
builder.Services.Configure<DistributionOptions>(o => o.DistributionType = EDistributionType.ExtractorFirst);
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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<IChannelInteractionModule, ChannelInteractionModule>();
|
||||
builder.Services.AddSingleton<IUntrustedInteractionModule, UdpUntrustedInteraction>();
|
||||
builder.Services.AddSingleton<IRepresentationModule, RepresentationModule>();
|
||||
var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 4567);
|
||||
var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 9000);
|
||||
builder.Services.AddSingleton<IFrontendBridge, NetworkFrontendBridge>();
|
||||
|
||||
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++)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+20
-6
@@ -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<int>[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<List<ILoadTest>> GetLoadEndpoints(int count)
|
||||
@@ -94,10 +103,12 @@ async Task<List<ILoadTest>> GetLoadEndpoints(int count)
|
||||
}
|
||||
}
|
||||
|
||||
async Task<int> Requests(CancellationToken token, int id, ILoadTest load)
|
||||
async Task<(int, double[])> Requests(CancellationToken token, int id, ILoadTest load)
|
||||
{
|
||||
try
|
||||
{
|
||||
var latencyList = new List<double>();
|
||||
var sw = new Stopwatch();
|
||||
int count = 0;
|
||||
while (true)
|
||||
{
|
||||
@@ -106,11 +117,14 @@ async Task<int> 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)
|
||||
{
|
||||
|
||||
@@ -10,12 +10,10 @@
|
||||
<ProjectReference Include="..\mROA.Cbor\mROA.Cbor.csproj" />
|
||||
<ProjectReference Include="..\mROA\mROA.csproj"/>
|
||||
<ProjectReference Include="..\mROA.Codegen\mROA.Codegen.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.7" />
|
||||
<PackageReference Include="mROA.Codegen" Version="2.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace Example.Shared
|
||||
{
|
||||
double Resource { get; set; }
|
||||
string GetName();
|
||||
Task<IPage> Print(string text, bool someParameter, RequestContext context, CancellationToken cancellationToken);
|
||||
Task<IPage> Print(string text, bool someParameter,
|
||||
RequestContext context, CancellationToken cancellationToken);
|
||||
event Action<IPage, RequestContext> OnPrint;
|
||||
|
||||
[Untrusted]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>3.0.3</Version>
|
||||
<Version>3.0.4</Version>
|
||||
<LangVersion>9</LangVersion>
|
||||
<PackageIcon>mroaLogo.png</PackageIcon>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Title>mROA</Title>
|
||||
<Version>3.0.3</Version>
|
||||
<Version>3.0.4</Version>
|
||||
<Authors>YaslePoy</Authors>
|
||||
<Description>Fast and easy RPC with contex</Description>
|
||||
<RepositoryUrl>https://github.com/YaslePoy/mROA</RepositoryUrl>
|
||||
|
||||
Reference in New Issue
Block a user