示例#1
0
 private void btnEncapsulatedDoubleInStruct_Click(object sender, EventArgs e)
 {
     benchmark("double in a struct[]", sender, () =>
     {
         var list = new List <Length[]>();
         for (var i = 0; i < 100; i++)
         {
             var array = new Length[100000];
             list.Add(array);
             for (var j = 0; j < 100; j++)
             {
                 TestLength.FillLengthArray(array);
             }
         }
         return(list.Sum(array => TestLength.ConvertToMiles(array).Sum()));
     });
 }
示例#2
0
 private void btnDoubleArray_Click(object sender, EventArgs e)
 {
     benchmark("double[]", sender, () =>
     {
         var list = new List <double[]>();
         for (var i = 0; i < 100; i++)
         {
             var array = new double[100000];
             list.Add(array);
             for (var j = 0; j < 100; j++)
             {
                 TestLength.FillMetersArray(array);
             }
         }
         return(list.Sum(array => TestLength.ConvertToMiles(array).Sum()));
     });
 }
示例#3
0
        private void btnDoubleStructArray_Click(object sender, EventArgs e)
        {
            benchmark("double in a struct[]", sender, () =>
            {
                var list = new List <Length[]>();
                for (var i = 0; i < 10; i++)
                {
                    var array = new Length[100000];
                    list.Add(array);
                    for (var j = 0; j < 100; j++)
                    {
                        TestLength.FillLengthArray(array);
                    }
                }

                double sumOfAverages = 0;
                for (int i = 0; i < 30; i++)
                {
                    var average    = list.Average(array => TestLength.ConvertToMiles(array).Average());
                    sumOfAverages += average;
                }
                return(sumOfAverages);
            });
        }
示例#4
0
        private void btnDoubleUnit_Click(object sender, EventArgs e)
        {
            benchmark("double+unit[]", sender, () =>
            {
                var list = new List <DoublePlusUnit[]>();
                for (var i = 0; i < 10; i++)
                {
                    var array = new DoublePlusUnit[100000];
                    list.Add(array);
                    for (var j = 0; j < 100; j++)
                    {
                        TestLength.FillDoublePlusUnitArrayWithMeters(array);
                    }
                }

                double sumOfAverages = 0;
                for (int i = 0; i < 30; i++)
                {
                    var average    = list.Average(array => TestLength.ConvertToMiles(array).Average());
                    sumOfAverages += average;
                }
                return(sumOfAverages);
            });
        }