unsafe static void Main(string[] args) { var w = 10_000; var h = 10_000; Console.OutputEncoding = Encoding.UTF8; Console.WriteLine($"Generating fractal map {w:N0} x {h:N0}..."); var data = PlasmaFractalGenerator.NewIslandMap(w, h, seed: Environment.TickCount); TimeSpan baseTime; // regular graph traversal { fixed(int *pData = data) { var sw = Stopwatch.StartNew(); var n = GraphTraversal.CountIslands(pData, w, h); baseTime = sw.Elapsed; if (w < Console.WindowWidth / 2 && h < Console.WindowWidth / 2) { RenderIslandMap(pData, w, h); } Console.WriteLine(); Console.WriteLine("Graph Traversal"); Console.WriteLine($" time: {baseTime}"); Console.WriteLine($" islands: {n}"); Reset(pData, w, h); } } // reconciliation algorithm { fixed(int *pData = data) { var sw = Stopwatch.StartNew(); var n = Reconciliation.CountIslands(pData, w, h); var time = sw.Elapsed; Console.WriteLine(); Console.WriteLine("Reconciliation"); Console.WriteLine($" time: {time}"); Console.WriteLine($" islands: {n}"); Console.WriteLine($" speedup: {baseTime.TotalMilliseconds / time.TotalMilliseconds:N1}X"); Reset(pData, w, h); } } // parallel reconciliation algorithm { fixed(int *pData = data) { var dop = Environment.ProcessorCount; var sw = Stopwatch.StartNew(); var n = ParallelReconciliation.CountIslands(pData, w, h, threadCount: dop); var time = sw.Elapsed; Console.WriteLine(); Console.WriteLine($"Parallel Reconciliation (DoP: {dop})"); Console.WriteLine($" time: {time}"); Console.WriteLine($" islands: {n}"); Console.WriteLine($" speedup: {baseTime.TotalMilliseconds / time.TotalMilliseconds:N1}X"); } } Console.WriteLine(); }