public static byte[] WriteFullAndDispose(this SyncSourceRoot syncSourceRoot) { using WriteSession session = syncSourceRoot.BeginWrite(); return(session.WriteFull()); }
public static byte[] WriteFullAndDispose(this SourceSynchronizerRoot SourceSynchronizerRoot) { using WriteSession session = SourceSynchronizerRoot.BeginWrite(); return(session.WriteFull()); }
private static void RunMonoSyncTest(int entityCount) { Console.WriteLine(); Console.WriteLine($"Benchmark with {entityCount} entities"); // Initialization Console.Write("Initializing: "); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var world = new MonoSyncWorld(); var syncSourceRoot = new SourceSynchronizerRoot(world); using (world.Entities.BeginMassUpdate()) { for (int i = 0; i < entityCount; i++) { world.Entities.Add(i, new Entity()); } } stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds + "MS"); stopwatch.Reset(); // Full write Console.Write("Full write: "); stopwatch.Start(); WriteSession fullWriteSession = syncSourceRoot.BeginWrite(); var syncTargetRoot = new TargetSynchronizerRoot <MonoSyncWorld>(fullWriteSession.WriteFull()); fullWriteSession.Dispose(); stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds + "MS"); stopwatch.Reset(); int changes = entityCount / 10; Console.Write($"{changes} changes write: "); stopwatch.Start(); for (int i = 0; i < changes; i++) { world.Entities[i].XPos = 2; } using (WriteSession writeSession = syncSourceRoot.BeginWrite()) { var data = writeSession.WriteChanges().SetTick(TimeSpan.Zero); syncTargetRoot.Read(data); } stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds + "MS"); }