예제 #1
0
        private static double TimeMethodAppend(int problemSize, int repetitions = 5)
        {
            Stopwatch   sw      = new Stopwatch();
            List <long> results = new List <long>(repetitions);

            for (int r = 0; r < repetitions; r++)
            {
                #region setup
                // Build an array based vector that is as large as the problem size
                ArrayBasedVector <int> arrayBasedVector = new ArrayBasedVector <int>();
                for (int i = 0; i < problemSize; i++)
                {
                    arrayBasedVector.Append(1);
                }
                #endregion

                // usually:
                // call method with the given problem size once...
                sw.Restart();
                arrayBasedVector.Append(1); // the problem size happens because the arrayBasedVector is large (it has a number of elements equal to the Problem Size)
                sw.Stop();

                results.Add(sw.ElapsedTicks);
            }

            return(results.Average());
        }
 public void Enqueue(T element)
 {
     vector.Append(element);
 }