Skip to main content

MiniProfiler

A single MiniProfiler can be used to represent any number of steps/levels in a call-graph, via Step()

Totally baller.

Assembly: ServiceStack.NetFramework.dll
View Source
Declaration
[ExcludeMetadata]
[DataContract]
public class MiniProfiler : IProfiler, IDbProfiler

Properties

Id

Identifies this Profiler so it may be stored/cached.

Totally baller.

View Source
Declaration
[DataMember(Order = 1, Name = "Id")]
public Guid Id { get; set; }

Name

A display name for this profiling session.

Totally baller.

View Source
Declaration
[DataMember(Order = 2, Name = "Name")]
public string Name { get; set; }

Started

When this profiler was instantiated.

Totally baller.

View Source
Declaration
[DataMember(Order = 3, Name = "Started")]
public DateTime Started { get; set; }

MachineName

Where this profiler was run.

Totally baller.

View Source
Declaration
[DataMember(Order = 4, Name = "MachineName")]
public string MachineName { get; set; }

Level

Allows filtering of ServiceStack.MiniProfiler.Timing steps based on what ServiceStack.MiniProfiler.ProfileLevel the steps are created with.

Totally baller.

View Source
Declaration
[DataMember(Order = 5, Name = "Level")]
public ProfileLevel Level { get; set; }

Root

The first ServiceStack.MiniProfiler.Timing that is created and started when this profiler is instantiated. All other ServiceStack.MiniProfiler.Timings will be children of this one.

Totally baller.

View Source
Declaration
[DataMember(Order = 6, Name = "Root")]
public Timing Root { get; set; }

User

A string identifying the user/client that is profiling this request. Set MiniProfiler.Settings.UserProvider with an ServiceStack.MiniProfiler.IUserProvider-implementing class to provide a custom value.

Totally baller.

View Source
Declaration
[DataMember(Order = 7, Name = "User")]
public string User { get; set; }

HasUserViewed

Returns true when this MiniProfiler has been viewed by the ServiceStack.MiniProfiler.MiniProfiler.User that recorded it.

Totally baller.

View Source
Declaration
[DataMember(Order = 8, Name = "HasUserViewed")]
public bool HasUserViewed { get; set; }

DurationMilliseconds

Milliseconds, to one decimal place, that this MiniProfiler ran.

Totally baller.

View Source
Declaration
[DataMember(Order = 9, Name = "DurationMilliseconds")]
public decimal DurationMilliseconds { get; }

HasTrivialTimings

Returns true when ServiceStack.MiniProfiler.MiniProfiler.Root or any of its ServiceStack.MiniProfiler.Timing.Children are ServiceStack.MiniProfiler.Timing.IsTrivial.

Totally baller.

View Source
Declaration
[DataMember(Order = 10, Name = "HasTrivialTimings")]
public bool HasTrivialTimings { get; }

HasAllTrivialTimings

Returns true when all child ServiceStack.MiniProfiler.Timings are ServiceStack.MiniProfiler.Timing.IsTrivial.

Totally baller.

View Source
Declaration
[DataMember(Order = 11, Name = "HasAllTrivialTimings")]
public bool HasAllTrivialTimings { get; }

TrivialDurationThresholdMilliseconds

Any Timing step with a duration less than or equal to this will be hidden by default in the UI; defaults to 2.0 ms.

Totally baller.

View Source
Declaration
[DataMember(Order = 12, Name = "TrivialDurationThresholdMilliseconds")]
public decimal TrivialDurationThresholdMilliseconds { get; }

Json

Json representing the collection of CustomTimings relating to this Profiler

Totally baller.

View Source
Declaration
[DataMember(Order = 13, Name = "Json")]
public string Json { get; set; }

Head

Points to the currently executing Timing.

Totally baller.

View Source
Declaration
public Timing Head { get; set; }

Current

Gets the currently running MiniProfiler for the current HttpContext; null if no MiniProfiler was Started.

Totally baller.

View Source
Declaration
public static MiniProfiler Current { get; }

DurationMillisecondsInSql

Milliseconds, to one decimal place, that this MiniProfiler was executing sql.

Totally baller.

View Source
Declaration
[DataMember(Order = 14, Name = "DurationMillisecondsInSql")]
public decimal DurationMillisecondsInSql { get; }

HasSqlTimings

Returns true when we have profiled queries.

Totally baller.

View Source
Declaration
[DataMember(Order = 15, Name = "HasSqlTimings")]
public bool HasSqlTimings { get; set; }

HasDuplicateSqlTimings

Returns true when any child Timings have duplicate queries.

Totally baller.

View Source
Declaration
[DataMember(Order = 16, Name = "HasDuplicateSqlTimings")]
public bool HasDuplicateSqlTimings { get; set; }

ExecutedReaders

How many sql data readers were executed in all ServiceStack.MiniProfiler.Timing steps.

Totally baller.

View Source
Declaration
[DataMember(Order = 17, Name = "ExecutedReaders")]
public int ExecutedReaders { get; }

ExecutedScalars

How many sql scalar queries were executed in all ServiceStack.MiniProfiler.Timing steps.

Totally baller.

View Source
Declaration
[DataMember(Order = 18, Name = "ExecutedScalars")]
public int ExecutedScalars { get; }

ExecutedNonQueries

How many sql non-query statements were executed in all ServiceStack.MiniProfiler.Timing steps.

Totally baller.

View Source
Declaration
[DataMember(Order = 19, Name = "ExecutedNonQueries")]
public int ExecutedNonQueries { get; }

IDbProfiler.IsActive

View Source
Declaration
bool IDbProfiler.IsActive { get; }

Methods

ToString()

Returns the ServiceStack.MiniProfiler.MiniProfiler.Root's ServiceStack.MiniProfiler.Timing.Name and ServiceStack.MiniProfiler.MiniProfiler.DurationMilliseconds this profiler recorded.

View Source
Declaration
public override string ToString()
Returns

System.String

Equals(Object)

Returns true if Ids match.

View Source
Declaration
public override bool Equals(object obj)
Returns

System.Boolean

Parameters
TypeName
System.Objectobj

GetHashCode()

Returns hashcode of Id.

View Source
Declaration
public override int GetHashCode()
Returns

System.Int32

Step(String)

View Source
Declaration
public IDisposable Step(string name)
Returns

System.IDisposable

Parameters
TypeName
System.Stringname

GetTimingHierarchy()

Walks the ServiceStack.MiniProfiler.Timing hierarchy contained in this profiler, starting with ServiceStack.MiniProfiler.MiniProfiler.Root, and returns each Timing found.

View Source
Declaration
public IEnumerable<Timing> GetTimingHierarchy()
Returns

System.Collections.Generic.IEnumerable<ServiceStack.MiniProfiler.Timing>

Start()

View Source
Declaration
public IProfiler Start()
Returns

ServiceStack.MiniProfiler.IProfiler

Stop()

View Source
Declaration
public void Stop()

Start(ProfileLevel)

Starts a new MiniProfiler based on the current ServiceStack.MiniProfiler.IProfilerProvider. This new profiler can be accessed by ServiceStack.MiniProfiler.MiniProfiler.Current

View Source
Declaration
public static MiniProfiler Start(ProfileLevel level)
Returns

ServiceStack.MiniProfiler.MiniProfiler

Parameters
TypeName
ServiceStack.MiniProfiler.ProfileLevellevel

Stop(Boolean)

Ends the current profiling session, if one exists.

View Source
Declaration
public static void Stop(bool discardResults)
Parameters
TypeNameDescription
System.BooleandiscardResults

When true, clears the ServiceStack.MiniProfiler.MiniProfiler.Current for this HttpContext, allowing profiling to be prematurely stopped and discarded. Useful for when a specific route does not need to be profiled.

|

StepStatic(String, ProfileLevel)

Returns an System.IDisposable that will time the code between its creation and disposal. Use this method when you do not wish to include the MvcMiniProfiler namespace for the ServiceStack.MiniProfiler.MiniProfilerExtensions.Step(ServiceStack.MiniProfiler.IProfiler%2cSystem.String%2cServiceStack.MiniProfiler.ProfileLevel) extension method.

View Source
Declaration
public static IDisposable StepStatic(string name, ProfileLevel level = ProfileLevel.Info)
Returns

System.IDisposable

Parameters
TypeNameDescription
System.StringnameA descriptive name for the code that is encapsulated by the resulting IDisposable's lifetime.

| | ServiceStack.MiniProfiler.ProfileLevel | level | This step's visibility level; allows filtering when MiniProfiler.Start is called.

|

RenderIncludes(Nullable<RenderPosition>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, Boolean, Nullable<Boolean>)

Returns the css and javascript includes needed to display the MiniProfiler results UI.

View Source
Declaration
public IHtmlString RenderIncludes(RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool xhtml = false, bool? showControls = null)
Returns

ServiceStack.IHtmlString: Script and link elements normally; an empty string when there is no active profiling session.

Parameters
TypeNameDescription
System.Nullable<ServiceStack.MiniProfiler.RenderPosition>positionWhich side of the page the profiler popup button should be displayed on (defaults to left)

| | System.Nullable<System.Boolean> | showTrivial | Whether to show trivial timings by default (defaults to false)

| | System.Nullable<System.Boolean> | showTimeWithChildren | Whether to show time the time with children column by default (defaults to false)

| | System.Nullable<System.Int32> | maxTracesToShow | The maximum number of trace popups to show before removing the oldest (defaults to 15)

| | System.Boolean | xhtml | xhtml rendering mode, ensure script tag is closed ... etc

| | System.Nullable<System.Boolean> | showControls | when true, shows buttons to minimize and clear MiniProfiler results

|

ToJson()

Renders the current ServiceStack.MiniProfiler.MiniProfiler to json.

View Source
Declaration
public static string ToJson()
Returns

System.String

ToJson(MiniProfiler)

Renders the parameter ServiceStack.MiniProfiler.MiniProfiler to json.

View Source
Declaration
public static string ToJson(MiniProfiler profiler)
Returns

System.String

Parameters
TypeName
ServiceStack.MiniProfiler.MiniProfilerprofiler

FromJson(String)

Deserializes the json string parameter to a ServiceStack.MiniProfiler.MiniProfiler.

View Source
Declaration
public static MiniProfiler FromJson(string json)
Returns

ServiceStack.MiniProfiler.MiniProfiler

Parameters
TypeName
System.Stringjson

Clone()

Create a DEEP clone of this object

View Source
Declaration
public MiniProfiler Clone()
Returns

ServiceStack.MiniProfiler.MiniProfiler

GetInProgressCommands()

Returns all currently open commands on this connection

View Source
Declaration
public SqlTiming[] GetInProgressCommands()
Returns

ServiceStack.MiniProfiler.SqlTiming[]

GetSqlTimings()

Returns all ServiceStack.MiniProfiler.SqlTiming results contained in all child ServiceStack.MiniProfiler.Timing steps.

View Source
Declaration
public List<SqlTiming> GetSqlTimings()
Returns

System.Collections.Generic.List<ServiceStack.MiniProfiler.SqlTiming>

IDbProfiler.ExecuteStart(DbCommand, ExecuteType)

View Source
Declaration
void IDbProfiler.ExecuteStart(DbCommand profiledDbCommand, ExecuteType executeType)
Parameters
TypeName
System.Data.Common.DbCommandprofiledDbCommand
ServiceStack.MiniProfiler.Data.ExecuteTypeexecuteType

IDbProfiler.ExecuteFinish(DbCommand, ExecuteType, DbDataReader)

View Source
Declaration
void IDbProfiler.ExecuteFinish(DbCommand profiledDbCommand, ExecuteType executeType, DbDataReader reader)
Parameters
TypeName
System.Data.Common.DbCommandprofiledDbCommand
ServiceStack.MiniProfiler.Data.ExecuteTypeexecuteType
System.Data.Common.DbDataReaderreader

IDbProfiler.ReaderFinish(DbDataReader)

View Source
Declaration
void IDbProfiler.ReaderFinish(DbDataReader reader)
Parameters
TypeName
System.Data.Common.DbDataReaderreader

IDbProfiler.OnError(DbCommand, ExecuteType, Exception)

View Source
Declaration
void IDbProfiler.OnError(DbCommand profiledDbCommand, ExecuteType executeType, Exception exception)
Parameters
TypeName
System.Data.Common.DbCommandprofiledDbCommand
ServiceStack.MiniProfiler.Data.ExecuteTypeexecuteType
System.Exceptionexception

Implements