Time an Action - CSharp System

CSharp examples for System:Action

Description

Time an Action

Demo Code


using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using System;/*  www . j a  v a2  s.  co m*/

public class Main{
        public static double Action(Action ac)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            ac?.Invoke();
            sw.Stop();

            return sw.Elapsed.TotalMilliseconds;
        }
}

Related Tutorials