Ejemplo n.º 1
0
        public static void ListTuple()
        {
            var t = new Timer();
            t.Start();
            var listUnderTest = new List<Tuple<long, int, string>>();
            for (long i = 0; i < _itemsInLoop1; i++)
            {
                for (int j = 0; j < _itemsInLoop2; j++)
                {
                    listUnderTest.Add(Tuple.Create(i, j, _brownCow));
                }
            }

            t.Stop();
            WriteResult("List Tuple", t);
            GC.Collect();
        }
Ejemplo n.º 2
0
        public static void ListAnonoymusType()
        {
            var t = new Timer();
            t.Start();
            List<dynamic> listUnderTest = new List<dynamic>();
            for (long i = 0; i < _itemsInLoop1; i++)
            {
                for (int j = 0; j < _itemsInLoop2; j++)
                {
                    listUnderTest.Add(new { Key1 = i, Key2 = j, Value = _brownCow });
                }
            }
            t.Stop();

            WriteResult("List anonymous", t);
            GC.Collect();
        }
Ejemplo n.º 3
0
        public static void StringTest()
        {
            var listUnderTest = new List<string>();
            var t = new Timer();
            t.Start();
            for (long i = 0; i < _itemsInLoop1; i++)
            {
                for (int j = 0; j < _itemsInLoop2; j++)
                {
                    string item = string.Format(_itemTemplate, i, j);
                    listUnderTest.Add(item);
                }
            }
            t.Stop();

            WriteResult("String list", t);
            GC.Collect();
        }
Ejemplo n.º 4
0
        public static void StringBuilderToArrayTest()
        {

            var t = new Timer();
            t.Start();
            var sb = new StringBuilder();
            for (long i = 0; i < _itemsInLoop1; i++)
            {
                for (int j = 0; j < _itemsInLoop2; j++)
                {
                    string item = string.Format(_itemTemplate, i, j);
                    sb.Append(item);
                }
            }
            var s = sb.ToString().Split('|');
            t.Stop();

            WriteResult("String Builder ToArray", t);
            GC.Collect();
        }
Ejemplo n.º 5
0
        public static void ListClassTest()
        {
            var t = new Timer();
            t.Start();
            var listUnderTest = new List<TestClass>();
            for (long i = 0; i < _itemsInLoop1; i++)
            {
                for (int j = 0; j < _itemsInLoop2; j++)
                {
                    var ts = new TestClass();
                    ts.Key1 = i;
                    ts.Key2 = j;
                    ts.Value = _brownCow;
                    listUnderTest.Add(ts);
                }
            }
            t.Stop();

            WriteResult("List class", t);
            GC.Collect();
        }