/// <summary> /// Creates a new Timing named 'name' in the 'profiler's session, with 'parent' as this Timing's immediate ancestor. /// </summary> public Timing(MiniProfiler profiler, Timing parent, string name) { this.Id = Guid.NewGuid(); Profiler = profiler; Profiler.Head = this; if (parent != null) // root will have no parent { parent.AddChild(this); } Name = name; _startTicks = profiler.ElapsedTicks; StartMilliseconds = profiler.GetRoundedMilliseconds(_startTicks); }
/// <summary> /// Creates a new SqlTiming to profile 'command'. /// </summary> public SqlTiming(DbCommand command, ExecuteType type, MiniProfiler profiler) { Id = Guid.NewGuid(); CommandString = AddSpacesToParameters(command.CommandText); Parameters = GetCommandParameters(command); ExecuteType = type; if (!MiniProfiler.Settings.ExcludeStackTraceSnippetFromSqlTimings) { StackTraceSnippet = ServiceStack.MiniProfiler.Helpers.StackTraceSnippet.Get(); } _profiler = profiler; if (_profiler != null) { _profiler.AddSqlTiming(this); _startTicks = _profiler.ElapsedTicks; StartMilliseconds = _profiler.GetRoundedMilliseconds(_startTicks); } }
private decimal GetDurationMilliseconds() { return(_profiler.GetRoundedMilliseconds(_profiler.ElapsedTicks - _startTicks)); }