private static DiffResult DoBenchmark(Differs.Differs.IGeometryDiff differ, string differName, DiffData payload) { var original = ReadWkb(payload.OldGeom); var modified = ReadWkb(payload.NewGeom); var stopwatch = new Stopwatch(); Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(2); // Uses the second Core or Processor for the Test Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; // Prevents "Normal" processes // from interrupting Threads Thread.CurrentThread.Priority = ThreadPriority.Highest; // Prevents "Normal" Threads from interrupting this thread stopwatch.Reset(); stopwatch.Start(); var patch = differ.CreatePatch(original, modified); stopwatch.Stop(); var createPatchTime = ((double)stopwatch.ElapsedTicks / Stopwatch.Frequency) * 1000; stopwatch.Reset(); stopwatch.Start(); var patched = differ.ApplyPatch(original, patch); stopwatch.Stop(); var applyPatchTime = ((double)stopwatch.ElapsedTicks / Stopwatch.Frequency) * 1000; stopwatch.Reset(); stopwatch.Start(); var unPatched = differ.UndoPatch(modified, patch); stopwatch.Stop(); var undoPatchTime = ((double)stopwatch.ElapsedTicks / Stopwatch.Frequency) * 1000; var forwardCorrect = patched != null && modified.EqualsExact(patched, 0.0000001); var undoCorrect = unPatched != null && original.EqualsExact(unPatched, 0.0000001); return(new DiffResult() { CreateTime = createPatchTime, ApplyTime = applyPatchTime, UndoTime = undoPatchTime, PatchSize = patch.Length, ForwardCorrect = forwardCorrect, UndoCorrect = undoCorrect, Differ = differName, GeomId = payload.GeometryId }); }
public static DiffResult GeomDiffer([ActivityTrigger] DiffData payload, ILogger log) { log.LogInformation($"Run GeomDiffer"); return(DoBenchmark(new GeomDiffer(), "GeomDiffer", payload)); }