Ejemplo n.º 1
0
        public static void ReadWriteTest <T>(ITitanicArray <T> arr, IDataIterator <T> iter)
        {
            long len = arr.Length;

            iter.Reset();
            for (long i = 0; i < len; i++)
            {
                arr[i] = iter.GetNext();
            }
            iter.Reset();
            for (long i = 0; i < len; i++)
            {
                Assert.IsTrue(iter.AreEqual(arr[i], iter.GetNext()));
            }
        }
Ejemplo n.º 2
0
        public static void TimingTest <T>(ITitanicArray <T> arr, IDataIterator <T> iter)
        {
            string name = "TimingTest " + arr.GetType().Name + "-" + iter.GetType().Name;

            var  s1  = Stopwatch.StartNew();
            long len = arr.Length;

            iter.Reset();
            for (long i = 0; i < len; i++)
            {
                arr[i] = iter.GetNext();
            }
            Debug.WriteLine(name + "\tw=" + s1.ElapsedMilliseconds);
            iter.Reset();
            for (long i = 0; i < len; i++)
            {
                Assert.IsTrue(iter.AreEqual(arr[i], iter.GetNext()));
            }
            Debug.WriteLine(name + "\tt=" + s1.ElapsedMilliseconds);
        }
Ejemplo n.º 3
0
        static void ReadAndTestRandom <T>(ITitanicArray <T> arr, IDataIterator <T> iter)
        {
            long len = arr.Length;
            var  seq = LinearFeedbackShiftRegister.SequenceLength(lfsrStart, (ulong)len).GetEnumerator();

            iter.Reset();
            for (long i = 0; i < len; i++)
            {
                seq.MoveNext();
                long x    = (long)seq.Current;
                T    next = iter.GetNext();
                Assert.IsTrue(iter.AreEqual(arr[x], next));
            }
        }
Ejemplo n.º 4
0
        static void WriteRandom <T>(ITitanicArray <T> arr, IDataIterator <T> iter)
        {
            long len = arr.Length;
            var  seq = LinearFeedbackShiftRegister.SequenceLength(lfsrStart, (ulong)len).GetEnumerator();

            iter.Reset();
            for (long i = 0; i < len; i++)
            {
                seq.MoveNext();
                long x    = (long)seq.Current;
                T    next = iter.GetNext();
                arr[x] = next;
            }
        }