예제 #1
0
        public void PerfTestRandomRead()
        {
            var systemList = new System.Collections.Generic.List <int>();

            var testedList = new SingleList <int>();

            for (int i = 0; i < 50000; i++)
            {
                testedList.Add(BenchmarkData[i]);
                systemList.Add(BenchmarkData[i]);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < systemList.Count; i++)
            {
                var index = BenchmarkData[i % 50];
                var it    = systemList[index];
            }
            stopwatch.Stop();
            var systemListTime = stopwatch.ElapsedTicks;

            stopwatch.Restart();
            for (int i = 0; i < testedList.Count; i++)
            {
                var index = BenchmarkData[i % 50];
                var it    = testedList[index];
            }
            stopwatch.Stop();
            output.WriteLine($"LinkedList {stopwatch.ElapsedTicks} t | System.List {systemListTime} t");
        }
예제 #2
0
 public LinqTests()
 {
     foreach (var dog in _dogListSystem)
     {
         _dogListTest.Add(dog);
     }
 }
예제 #3
0
 public SingleListTests()
 {
     foreach (var value in _intListSystem)
     {
         _intListTested.Add(value);
     }
 }
예제 #4
0
        private static void IndexComparisonHelper <T>(params T[] data)
        {
            //Comparing to a list here just because it implements all the operations.
            //No particular reason this colleciton was chosen.
            var systemList = new List <T>(data);

            var testedList = new SingleList <T>();

            foreach (var value in systemList)
            {
                testedList.Add(value);
            }
            //Index Test
            foreach (var value in systemList)
            {
                var correctIndex = systemList.IndexOf(value);
                var testedIndex  = testedList.IndexOf(value);
                Assert.Equal(correctIndex, testedIndex);
                Assert.True(testedList.Contains(value));
            }
            //Removal Tests
            for (int i = 0; i < data.Length; i++)
            {
                //Let's check it behaves in a manner identical to deference list
                Assert.Equal(testedList.Remove(data[2]), systemList.Remove(data[2]));
                Assert.Equal(testedList.Count, systemList.Count);
            }
        }
예제 #5
0
        public void PerfTestSequentialRead()
        {
            var systemList       = new System.Collections.Generic.List <int>(BenchmarkData);
            var systemLinkedList = new System.Collections.Generic.LinkedList <int>(BenchmarkData);

            var testedLinkedList = new SingleList <int>();

            foreach (var number in BenchmarkData)
            {
                testedLinkedList.Add(number);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < BenchmarkData.Length; i++)
            {
                var it = systemList[i];
            }
            stopwatch.Stop();
            var systemListDuration = stopwatch.ElapsedMilliseconds;

            stopwatch.Restart();
            foreach (var item in systemLinkedList)
            {
                var it = item;
            }
            stopwatch.Stop();
            var systemLinkedListDuration = stopwatch.ElapsedMilliseconds;

            stopwatch.Restart();
            for (int i = 0; i < BenchmarkData.Length; i++)
            {
                var it = testedLinkedList[i];
            }
            stopwatch.Stop();
            var linkedListIterated = stopwatch.ElapsedMilliseconds;

            stopwatch.Restart();
            //Tested this for comparison, it's about three times faster
            foreach (var item in testedLinkedList)
            {
                var it = item;
            }
            stopwatch.Stop();
            var linkedListEnumerated = stopwatch.ElapsedMilliseconds;

            output.WriteLine($"'Enumerator' {linkedListEnumerated} | Indexer | {linkedListIterated}| " +
                             $"System.List {systemListDuration}| System.LinkedList {systemLinkedListDuration}");
        }
예제 #6
0
        public void PerfTestInsert()
        {
            var       systemList = new System.Collections.Generic.LinkedList <int>();
            Stopwatch stopwatch  = new Stopwatch();

            stopwatch.Start();
            foreach (var number in BenchmarkData)
            {
                systemList.AddLast(number);
            }
            stopwatch.Stop();
            var SystemListTime = stopwatch.ElapsedMilliseconds;
            var testedList     = new SingleList <int>();

            stopwatch.Restart();
            foreach (var number in BenchmarkData)
            {
                testedList.Add(number);
            }
            stopwatch.Stop();
            output.WriteLine($"LinkedList {stopwatch.ElapsedMilliseconds}ms | System.LinkedList {SystemListTime}");
        }
예제 #7
0
        public void SingleList_Serialized()
        {
            int lc = 0;
              int cc = 0;
              Csla.Core.ChildChangedEventArgs cca = null;

              var root = new SingleList();
              root.Add(new SingleRoot(true));
              root = root.Clone();

            #if !SILVERLIGHT
              System.ComponentModel.PropertyDescriptor lcp = null;
              root.ListChanged += (o, e) =>
              {
            lc++;
            lcp = e.PropertyDescriptor;
              };
            #else
              root.CollectionChanged += (o, e) =>
              {
            lc++;
              };
            #endif
              root.ChildChanged += (o, e) =>
              {
            cc++;
            cca = e;
              };
              root[0].Name = "abc";
            #if !SILVERLIGHT
              Assert.AreEqual(1, lc, "ListChanged should have fired");
              Assert.IsNotNull(lcp, "PropertyDescriptor should be provided");
              Assert.AreEqual("Name", lcp.Name, "PropertyDescriptor.Name should be Name");
            #endif
              Assert.AreEqual(1, cc, "ChildChanged should have fired");
              Assert.IsTrue(ReferenceEquals(root[0], cca.ChildObject), "Ref should be equal");
        }