Ejemplo n.º 1
0
        public void PerformanceTestDX()
        {
            Stopwatch sw = Stopwatch.StartNew();


            CaptureDX(cur);

            TimeSpan timetoCapture = sw.Elapsed;
            var      locked1       = cur.LockBits(new Rectangle(0, 0, cur.Width, cur.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            var      locked2       = prev.LockBits(new Rectangle(0, 0, prev.Width, prev.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

            try
            {
                XOR.CountDifference(locked2, locked1, this.compressionBuffer);

                TimeSpan timeToXor = sw.Elapsed;

                compressedScreen.Size = LZ4.LZ4Codec.Encode(compressionBuffer, 0, compressionBuffer.Length, compressedScreen.Data, 0, compressedScreen.Data.Length);

                TimeSpan timeToCompress = sw.Elapsed;


                Console.WriteLine("Iteration: {0}ms, {1}ms, {2}ms, " + "{3} Kb => {4:0.0} FPS     \r", timetoCapture.TotalMilliseconds, timeToXor.TotalMilliseconds,
                                  timeToCompress.TotalMilliseconds, compressedScreen.Size / 1024, 1.0 / sw.Elapsed.TotalSeconds);


                var tmp = cur;
                cur  = prev;
                prev = tmp;
            }
            finally
            {
                cur.UnlockBits(locked1);
                prev.UnlockBits(locked2);
            }
        }