Jazyk: C#
Vloženo: 16.12.2009, 22:36
Stáhnout jako soubor
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace PixelTest { class Program { unsafe static void Main(string[] args) { DateTime start = DateTime.Now; int width = 800; int height = 600; WriteInfo("malloc(" + width + ", " + height + ")", start); start = DateTime.Now; for (int i = 0; i != width; i++) { for (int j = 0; j != height; j++) { } } WriteInfo("init(" + width + ", " + height + ")", start); while (true) { start = DateTime.Now; Col* arrayPtr = null; for (int i = 0; i != width; i++) { fixed (Col* ptr = &array[i, 0]) { arrayPtr = ptr; for (int j = 0; j != height; j++) { arrayPtr->a = (arrayPtr->b) * (arrayPtr->c); arrayPtr->b = (arrayPtr->a) * (arrayPtr->c); arrayPtr->c = (arrayPtr->a) * (arrayPtr->b); arrayPtr++; } } } Console.SetCursorPosition(0, 2); WriteInfo("re-set(" + width + ", " + height + ")", start); } } static void WriteInfo(string prefix, DateTime start) { Console.WriteLine(prefix + ": " + Math.Round((DateTime.Now - start).TotalMilliseconds) + " ms -> " + Math.Round(1000 / (DateTime.Now - start).TotalMilliseconds) + " fps "); } } struct Col { public float a; public float b; public float c; public Col(float a, float b, float c) { this.a = a; this.b = b; this.c = c; } } }
© 2006 Michal Tuláček, Syntax Highlight - GeSHi (thx bref)