public static void Main(string[] args) { var StopWatch = new StopWatch(); StopWatch.Start(); IBootstrapper Bootstrapper = Utilities.IoC.Manager.Bootstrapper; StopWatch.Stop(); Console.WriteLine("Start up: " + StopWatch.ElapsedTime); using (IDisposable StartProfiler = Utilities.Profiler.Profiler.StartProfiling()) { var Rand = new System.Random(); SingleSourceCached(Rand); MultipleSourceCached(Rand); MultipleSourceCachedCascade(Rand); } Console.WriteLine(Utilities.Profiler.Profiler.StopProfiling(false).ToString()); QueryProvider.Batch("Data Source=localhost;Initial Catalog=SpeedTest;Integrated Security=SSPI;Pooling=false") .AddCommand(null, null, CommandType.Text, "ALTER DATABASE SpeedTest SET OFFLINE WITH ROLLBACK IMMEDIATE") .AddCommand(null, null, CommandType.Text, "ALTER DATABASE SpeedTest SET ONLINE") .AddCommand(null, null, CommandType.Text, "DROP DATABASE SpeedTest") .Execute(); Console.ReadKey(); }
/// <summary> /// Constructor /// </summary> /// <param name="FunctionName">Function/identifier</param> public Profiler(string FunctionName) { this.Parent = Current; Profiler Child = Parent != null && Parent.InternalChildren.ContainsKey(FunctionName) ? Parent.InternalChildren[FunctionName] : null; if (Child == null) { if (Parent != null) Parent.InternalChildren.Add(FunctionName, this); this.Function = FunctionName; this.InternalChildren = new Dictionary<string, Profiler>(); this.Entries = new List<IResultEntry>(); this.StopWatch = new StopWatch(); this.Level = Parent == null ? 0 : Parent.Level + 1; this.CalledFrom = new StackTrace().GetMethods(this.GetType().Assembly).ToString<MethodBase>(x => x.DeclaringType.Name + " > " + x.Name, "<br />"); Running = false; Current = this; Child = this; if (CPUCounter == null) CPUCounter = new PerformanceCounter("Processor Information", "% Processor Time", "_Total"); if (CounterStopWatch == null) { CounterStopWatch = new StopWatch(); CounterStopWatch.Start(); LastCounterTime = CounterStopWatch.ElapsedTime; } } else { Current = Child; } Start(); }