public static void Main(string[] args) { Console.WriteLine("FastBitmap (v1.2.0) Benchmarking App"); Console.WriteLine("------------------------------------------------"); // // Single-Core Passthrough Benchmarks // BenchmarkTest pt = new BenchmarkTest { Name = "Single-Core Passthrough Benchmark", IterationCount = 3 }; // System.Drawing.Bitmap Coord Benchmark pt.AddBenchmark("SysBitmap Coord", () => { using (Bitmap src = new Bitmap(Image.FromFile("image.jpg"))) using (Bitmap dst = new Bitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < dst.Width; x++) { for (int y = 0; y < dst.Height; y++) { dst.SetPixel(x, y, src.GetPixel(x, y)); } } sw.Stop(); dst.Save("SystemBitmap.jpg"); return(src.Width * src.Height / sw.Elapsed.TotalSeconds); } }); // FastBitmap Coord Benchmark pt.AddBenchmark("FastBitmap Coord", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < dst.Width; x++) { for (int y = 0; y < dst.Height; y++) { dst.Set(x, y, src.Get(x, y)); } } sw.Stop(); dst.Save("FastBitmapCoord.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // FastBitmap Index Benchmark pt.AddBenchmark("FastBitmap Index", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < dst.Length; i++) { dst.Set(i, src.Get(i)); } sw.Stop(); dst.Save("FastBitmapIndex.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // FastBitmap Int32 Coord Benchmark pt.AddBenchmark("FastBitmap Int32 Coord", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < dst.Width; x++) { for (int y = 0; y < dst.Height; y++) { dst.SetI(x, y, src.GetI(x, y)); } } sw.Stop(); dst.Save("FastBitmapInt32Coord.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // FastBitmap Int32 Index Benchmark pt.AddBenchmark("FastBitmap Int32 Index", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < dst.Length; i++) { dst.SetI(i, src.GetI(i)); } sw.Stop(); dst.Save("FastBitmapInt32Index.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // Run Passthrough pt.Run(); // Render Graph FastBitmap graph = pt.DrawGraph(); graph.Save("graph.png", ImageFormat.Png); graph.Dispose(); // Finished. Console.Write("\nAll Benchmarks Completed"); Console.Read(); }