/// <summary> /// Completes this Timing's duration and sets the MiniProfiler's Head up one level. /// </summary> public void Stop() { if (DurationMilliseconds == null) { DurationMilliseconds = Profiler.GetRoundedMilliseconds(Profiler.ElapsedTicks - _startTicks); Profiler.Head = ParentTiming; } }
/// <summary> /// Creates a new Timing named 'name' in the 'profiler's session, with 'parent' as this Timing's immediate ancestor. /// </summary> public Timing(Profiler 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, Profiler profiler) { Id = Guid.NewGuid(); CommandString = AddSpacesToParameters(command.CommandText); Parameters = GetCommandParameters(command); ExecuteType = type; if (!Profiler.Settings.ExcludeStackTraceSnippetFromSqlTimings) StackTraceSnippet = ServiceStack.MiniProfiler.Helpers.StackTraceSnippet.Get(); _profiler = profiler; if (_profiler != null) { _profiler.AddSqlTiming(this); _startTicks = _profiler.ElapsedTicks; StartMilliseconds = _profiler.GetRoundedMilliseconds(_startTicks); } }
/// <summary> /// Creates a new SqlTiming to profile 'command'. /// </summary> public SqlTiming(DbCommand command, ExecuteType type, Profiler profiler) { Id = Guid.NewGuid(); CommandString = AddSpacesToParameters(command.CommandText); Parameters = GetCommandParameters(command); ExecuteType = type; if (!Profiler.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)); }