private static void RunBenchmarkSwitcher(LoadResizeSaveParallelMemoryStress lrs, out Stopwatch timer) { Console.WriteLine(@"Choose a library for image resizing stress test: 1. System.Drawing 2. ImageSharp 3. MagicScaler 4. SkiaSharp 5. SkiaSharp - Decode to target size 6. NetVips 7. ImageMagick "); ConsoleKey key = Console.ReadKey().Key; if (key < ConsoleKey.D1 || key > ConsoleKey.D6) { Console.WriteLine("Unrecognized command."); Environment.Exit(-1); } timer = Stopwatch.StartNew(); switch (key) { case ConsoleKey.D1: lrs.SystemDrawingBenchmarkParallel(); break; case ConsoleKey.D2: lrs.ImageSharpBenchmarkParallel(); break; case ConsoleKey.D3: lrs.MagicScalerBenchmarkParallel(); break; case ConsoleKey.D4: lrs.SkiaBitmapBenchmarkParallel(); break; case ConsoleKey.D5: lrs.SkiaBitmapDecodeToTargetSizeBenchmarkParallel(); break; case ConsoleKey.D6: lrs.NetVipsBenchmarkParallel(); break; case ConsoleKey.D7: lrs.MagickBenchmarkParallel(); break; } timer.Stop(); }
public static void Run() { Console.WriteLine(@"Choose a library for image resizing stress test: 1. System.Drawing 2. ImageSharp 3. MagicScaler 4. SkiaSharp 5. NetVips 6. ImageMagick "); ConsoleKey key = Console.ReadKey().Key; if (key < ConsoleKey.D1 || key > ConsoleKey.D6) { Console.WriteLine("Unrecognized command."); return; } try { var lrs = new LoadResizeSaveParallelMemoryStress(); Console.WriteLine($"\nEnvironment.ProcessorCount={Environment.ProcessorCount}"); Console.WriteLine($"Running with MaxDegreeOfParallelism={lrs.benchmarks.MaxDegreeOfParallelism} ..."); var timer = Stopwatch.StartNew(); switch (key) { case ConsoleKey.D1: lrs.SystemDrawingBenchmarkParallel(); break; case ConsoleKey.D2: lrs.ImageSharpBenchmarkParallel(); break; case ConsoleKey.D3: lrs.MagicScalerBenchmarkParallel(); break; case ConsoleKey.D4: lrs.SkiaBitmapBenchmarkParallel(); break; case ConsoleKey.D5: lrs.NetVipsBenchmarkParallel(); break; case ConsoleKey.D6: lrs.MagickBenchmarkParallel(); break; } timer.Stop(); var stats = new Stats(timer, lrs.TotalProcessedMegapixels); Console.WriteLine("Done. TotalProcessedMegapixels: " + lrs.TotalProcessedMegapixels); Console.WriteLine(stats.GetMarkdown()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }