Ejemplo n.º 1
0
        /// <summary>
        /// Starts a new performance consumer and returns the instance that just started.
        /// </summary>
        /// <returns></returns>
        public static PerformanceInfoConsumer StartNew(string name)
        {
            var performance = new PerformanceInfoConsumer(name);

            performance.Start();
            return(performance);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests performance for the given action.
        /// </summary>
        public static void TestPerf(this Action action, string name)
        {
            var info = new PerformanceInfoConsumer(name);

            info.Start();
            action();
            info.Stop();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Tests performance for the given function.
        /// </summary>
        public static TResult TestPerf <T, TResult>(this Func <T, TResult> func, string name, T a)
        {
            var info = new PerformanceInfoConsumer(name);

            info.Start();
            var res = func(a);

            info.Stop();
            return(res);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Tests performance for the given function.
        /// </summary>
        public static T TestPerf <T>(this Func <T> func, string name)
        {
            var info = new PerformanceInfoConsumer(name);

            info.Start();
            var res = func();

            info.Stop();
            return(res);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Tests performance for the given action.
        /// </summary>
        public static void TestPerf(this Action action, string name, int count)
        {
            var info = new PerformanceInfoConsumer(name + " x " + count.ToInvariantString(), 10000);

            info.Start();
            while (count > 0)
            {
                action();
                count--;
            }
            info.Stop();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Tests performance for the given function.
        /// </summary>
        public static T TestPerf <T>(this Func <T> func, string name, int count)
        {
            var res  = default(T);
            var info = new PerformanceInfoConsumer(name + " x " + count.ToInvariantString(), 10000);

            info.Start();
            while (count > 0)
            {
                res = func();
                count--;
            }
            info.Stop();
            return(res);
        }