2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-04-29 06:48:41 +00:00
This commit is contained in:
2026-04-04 23:54:59 +03:00
parent 5b0fba89a4
commit 44983d7784
17 changed files with 181 additions and 66 deletions
@@ -7,4 +7,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\Esiur\Esiur.csproj" />
</ItemGroup>
</Project>
@@ -23,7 +23,7 @@ var proxies = new dynamic[resourceCount];
// --- Attach in batches to avoid overwhelming the runtime -------------
var totalSw = Stopwatch.StartNew();
var wh = new Warehouse();
for (int batch = 0; batch < resourceCount; batch += batchSize)
{
int end = Math.Min(batch + batchSize, resourceCount);
@@ -35,7 +35,7 @@ for (int batch = 0; batch < resourceCount; batch += batchSize)
batchTasks[i - batch] = Task.Run(async () =>
{
var sw = Stopwatch.StartNew();
proxies[capturedI] = await Warehouse.Get<IResource>(
proxies[capturedI] = await wh.Get<IResource>(
$"iip://{host}:{port}/sys/sensor_{capturedI}");
sw.Stop();
@@ -7,4 +7,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\Esiur\Esiur.csproj" OutputItemType="Analyzer"/>
</ItemGroup>
</Project>
@@ -8,25 +8,27 @@
using Esiur.Resource;
using Esiur.Stores;
using Esiur.Net.IIP;
using Esiur.Protocol;
var resourceCount = int.Parse(GetArg(args, "--resources", "10000"));
var port = int.Parse(GetArg(args, "--port", "10901"));
Console.WriteLine($"[Server-T2] Creating {resourceCount} resources on port {port}");
await Warehouse.Put("sys", new MemoryStore());
await Warehouse.Put("sys/server", new DistributedServer() { Port = (ushort)port });
var wh = new Warehouse();
await wh.Put("sys", new MemoryStore());
await wh.Put("sys/server", new EpServer() { Port = (ushort)port });
long memBefore = GC.GetTotalMemory(forceFullCollection: true);
for (int i = 0; i < resourceCount; i++)
{
var s = new SensorResource { SensorId = i, Value = i * 0.1 };
await Warehouse.Put($"sys/sensor_{i}", s);
await wh.Put($"sys/sensor_{i}", s);
}
await Warehouse.Open();
await wh.Open();
long memAfter = GC.GetTotalMemory(forceFullCollection: true);
double memMB = (memAfter - memBefore) / (1024.0 * 1024.0);
@@ -35,7 +37,7 @@ Console.WriteLine($"[Server-T2] Ready. Resources={resourceCount} MemoryUsed={me
Console.WriteLine($"[Server-T2] Per-resource ≈ {(memAfter - memBefore) / (double)resourceCount:F0} bytes");
Console.WriteLine("Press ENTER to stop.");
Console.ReadLine();
await Warehouse.Close();
await wh.Close();
static string GetArg(string[] args, string key, string def)
@@ -0,0 +1,15 @@
using Esiur.Resource;
/// <summary>
/// Shared observable sensor resource used across all scalability tests.
/// Property changes via Value setter are automatically propagated
/// to all attached remote peers by the Esiur runtime.
/// </summary>
[Resource]
public partial class SensorResource : Resource
{
public int SensorId { get; set; }
[Export]
public double value;
}