예제 #1
0
        private void TestByteArrayCopy(int size)
        {
            byte[] src = new byte[size];
            byte[] dst = new byte[size];

            mDebugger.Send($"Start Copy of {size} bytes");

            MemoryOperations.Fill(src, 42);

            mDebugger.Send("Copy Start");
            MemoryOperations.Copy(dst, src);
            mDebugger.Send("Copy End");

            Assert.AreEqual(src, dst, $"Copy failed Array src and dst with size {size} are not equals");

            mDebugger.Send("End");
        }
예제 #2
0
        private void TestIntArrayCopy(int size)
        {
            int[] src = new int[size];
            int[] dst = new int[size];

            mDebugger.Send($"Start Copy of {size} integers");

            MemoryOperations.Fill(src, 42);

            mDebugger.Send("Copy Start");
            MemoryOperations.Copy(dst, src);
            mDebugger.Send("Copy End");

            Assert.IsTrue(AreArrayEquals(src, dst), $"Copy failed Array src and dst with size {size} are not equals");

            mDebugger.Send("End");
        }
        public unsafe void Execute(string parameter = null)
        {
            if (parameter == null || !int.TryParse(parameter, out var length))
            {
                length = 64000;
            }
            var array  = new int[length];
            var points = new[]
            {
                4, 2, 3
            };

            fixed(int *dest = array)
            {
                MemoryOperations.Fill(dest, 42, length);
            }

            Console.WriteLine($"Voilà super rapide les {length} éléments ptdr *transition Leclerc*");
            var smallerLength = length / 4;
            var array2        = new int[smallerLength];
            var array3        = new int[smallerLength];
            var timeStamp     = CStopwatch.GetTimestamp();

            Console.WriteLine($"Test: {smallerLength} elements");
            // no pointer
            for (int i = 0; i < smallerLength; i++)
            {
                array2[i] = i + i * i;
            }
            Console.WriteLine($"Completed with no pointers in {CStopwatch.GetTimestamp() - timeStamp} units");
            timeStamp = CStopwatch.GetTimestamp();
            fixed(int *array3P = array3)
            {
                for (int i = 0; i < smallerLength; i++)
                {
                    *(array3P + i) = i + i * i;
                }
            }

            Console.WriteLine($"Completed with a pointy pointer in {CStopwatch.GetTimestamp() - timeStamp} units");
        }