Esempio n. 1
0
        /// <summary>
        /// Test speed of method
        /// </summary>
        /// <param name="method">Tested method</param>
        ///<param name="integers">array of parameters</param>
        /// <returns>Ticks count</returns>
        /// <exception cref="NullReferenceException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static long TestSpeed(MyTimerDelegate method, params int[] integers)
        {
            if (ReferenceEquals(method, null))
            {
                throw new NullReferenceException();
            }
            if (integers.Length < 0 || integers.Any(curent => curent < 0))
            {
                throw new ArgumentOutOfRangeException();
            }

            Stopwatch watch = new Stopwatch();

            watch.Start();
            method(integers);
            watch.Stop();
            return(watch.ElapsedTicks);
        }
Esempio n. 2
0
        /// <summary>
        /// Test speed of method
        /// </summary>
        /// <param name="method">Tested method</param>
        /// <param name="a">first parameter for method</param>
        /// <param name="b">second parameter for method</param>
        /// <returns>Ticks count</returns>
        /// <exception cref="NullReferenceException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static long TestSpeed(MyTimerDelegate method, int a, int b)
        {
            if (ReferenceEquals(method, null))
            {
                throw new NullReferenceException();
            }
            if (a < 0 || b < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            Stopwatch watch = new Stopwatch();

            watch.Start();
            method(a, b);
            watch.Stop();
            return(watch.ElapsedTicks);
        }
Esempio n. 3
0
 public MyTimer(MyTimerDelegate method, int interval, int ticksCount)
 {
     this.method     = method;
     this.Interval   = interval;
     this.TicksCount = ticksCount;
 }
 public MyTimer(MyTimerDelegate method, int interval, int ticksCount)
 {
     this.method = method;
     this.Interval = interval;
     this.TicksCount = ticksCount;
 }
Esempio n. 5
0
 public void TestSpeed_TestSpeed(MyTimerDelegate method, params int[] ints)
 {
     Console.WriteLine(ints.Length > 2
         ? TestSpeed(method, ints).ToString()
         : TestSpeed(method, ints[0], ints[1]).ToString());
 }