MvcMiniProfiler Formats any SQL query with inline parameters, optionally including the value type Takes a SqlTiming and returns a formatted SQL string, for parameter replacement, etc. Return SQL the way you want it to look on the in the trace. Usually used to format parameters Formatted SQL Creates a new Inline SQL Formatter, optionally including the parameter type info in comments beside the replaced value whether to include a comment after the value, indicating the type, e.g. /* @myParam DbType.Int32 */ Formats the SQL in a generic frieldly format, including the parameter type information in a comment if it was specified in the InlineFormatter constructor The SqlTiming to format A formatted SQL string Returns a string representation of the parameter's value, including the type The parameter to get a value for A single MiniProfiler can be used to represent any number of steps/levels in a call-graph, via Step() Totally baller. Starts when this profiler is instantiated. Each step will use this Stopwatch's current ticks as their starting time. Creates and starts a new MiniProfiler for the root , filtering steps to . Obsolete - used for serialization. Walks the hierarchy contained in this profiler, starting with , and returns each Timing found. Returns all results contained in all child steps. Returns milliseconds based on Stopwatch's Frequency. Starts a new MiniProfiler for the current Request. This new profiler can be accessed by Ends the current profiling session, if one exists. When true, clears the for this HttpContext, allowing profiling to be prematurely stopped and discarded. Useful for when a specific route does not need to be profiled. Returns an 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 extension method. A descriptive name for the code that is encapsulated by the resulting IDisposable's lifetime. This step's visibility level; allows filtering when is called. Returns the css and javascript includes needed to display the MiniProfiler results UI. Which side of the page the profiler popup button should be displayed on (defaults to left) Whether to show trivial timings by default (defaults to false) Whether to show time the time with children column by default (defaults to false) The maximum number of trace popups to show before removing the oldest (defaults to 15) Script and link elements normally; an empty string when there is no active profiling session. Renders the current to json. Renders the parameter to json. Deserializes the json string parameter to a . Create a DEEP clone of this object Identifies this Profiler so it may be stored/cached. A display name for this profiling session. When this profiler was instantiated. Where this profiler was run. Allows filtering of steps based on what the steps are created with. The first that is created and started when this profiler is instantiated. All other s will be children of this one. Contains information about queries executed during this profiling session. Milliseconds, to one decimal place, that this MiniProfiler ran. Milliseconds, to one decimal place, that this MiniProfiler was executing sql. Returns true when we have profiled queries. Returns true when any child Timings have duplicate queries. Returns true when or any of its are . Returns true when all child s are . 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. Ticks since this MiniProfiler was started. Points to the currently executing Timing. Gets the currently running MiniProfiler for the current HttpContext; null if no MiniProfiler was ed. Various configuration properties. Ensures that and objects are initialized. Null values will be initialized to use the default strategy. When true, link and script tags will be written to the response stream when MiniProfiler.Stop is called. 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. Dictates if the "time with children" column is displayed by default, defaults to false. For a per-page override you can use .RenderIncludes(showTimeWithChildren: true/false) Dictates if trivial timings are displayed by default, defaults to false. For a per-page override you can use .RenderIncludes(showTrivial: true/false) Determines how many traces to show before removing the oldest; defaults to 15. For a per-page override you can use .RenderIncludes(maxTracesToShow: 10) Dictates on which side of the page the profiler popup button is displayed; defaults to left. For a per-page override you can use .RenderIncludes(position: RenderPosition.Left/Right) When is called, if the current request url starts with this property, no profiler will be instantiated and no results will be displayed. Default value is { "/mini-profiler-includes.js", "/mini-profiler-includes.less", "/mini-profiler-results", "/content/", "/scripts/" }. The path under which ALL routes are registered in, defaults to the application root. For example, "~/myDirectory/" would yield "/myDirectory/mini-profiler-includes.js" rather than just "/mini-profiler-includes.js" Any setting here should be in APP RELATIVE FORM, e.g. "~/myDirectory/" Understands how to save and load MiniProfilers for a very limited time. Used for caching between when a profiling session ends and results can be fetched to the client. The normal profiling session life-cycle is as follows: 1) request begins 2) profiler is started 3) normal page/controller/request execution 4) profiler is stopped 5) profiler is cached with 's implementation of 6) request ends 7) page is displayed and profiling results are ajax-fetched down, pulling cached results from 's implementation of Understands how to save and load MiniProfilers for an extended (even indefinite) time, allowing results to be shared with other developers or even tracked over time. The formatter applied to the SQL being rendered (used only for UI) Assembly version of this dank MiniProfiler. A function that determines who can access the MiniProfiler results url. It should return true when the request client has access, false for a 401 to be returned. HttpRequest parameter is the current request and MiniProfiler parameter is the results that were profiled. Both the HttpRequest and MiniProfiler parameters that will be passed into this function should never be null. Categorizes individual steps to allow filtering. Default level given to Timings. Useful when profiling many items in a loop, but you don't wish to always see this detail. Dictates on which side of the page the profiler popup button is displayed; defaults to left. Profiler popup button is displayed on the left. Profiler popup button is displayed on the right. Contains helper methods that ease working with null s. Wraps in a call and executes it, returning its result. The current profiling session or null. Method to execute and profile. The step name used to label the profiler results. Returns an that will time the code between its creation and disposal. The current profiling session or null. A descriptive name for the code that is encapsulated by the resulting IDisposable's lifetime. This step's visibility level; allows filtering when is called. Adds 's hierarchy to this profiler's current Timing step, allowing other threads, remote calls, etc. to be profiled and joined into this profiling session. Returns an html-encoded string with a text-representation of ; returns "" when profiler is null. The current profiling session or null. Execute parameterized SQL Number of rows affected Return a list of dynamic objects, reader is closed after the call Execute a command that returns multiple result sets, and access each in turn Return a typed list of objects, reader is closed after the call Maps a query to objects The return type The Field we should split and read the second object from (default: id) Number of seconds before command execution timeout This is a micro-cache; suitable when the number of terms is controllable (a few hundred, for example), and strictly append-only; you cannot change existing values. All key matches are on **REFERENCE** equality. The type is fully thread-safe. Read the next grid of results This is a micro-cache; suitable when the number of terms is controllable (a few hundred, for example), and strictly append-only; you cannot change existing values. All key matches are on **REFERENCE** equality. The type is fully thread-safe. Provides saving and loading s to a storage medium. Stores under , which is also its . The Guid that identifies the MiniProfiler; subsequent calls to will pass this Guid. The results of a profiling session. Should be able to be called multiple times on the same profiler. Returns a from storage based on . NOT IMPLEMENTED - will format statements with paramters in an Oracle friendly way Does NOTHING, implement me! Understands how to store a to a MSSQL database. Understands how to save MiniProfiler results to a MSSQL database, allowing more permanent storage and querying of slow results. Returns a new SqlServerDatabaseStorage object that will insert into the database identified by connectionString. Saves 'profiler' to a database under 'id'. Returns the MiniProfiler identified by 'id' from the database or null when no MiniProfiler exists under that 'id'. Returns a DbConnection for your specific provider. Returns a DbConnection already opened for execution. Giving freshly selected collections, this method puts them in the correct hierarchy under the 'result' MiniProfiler. How we connect to the database used to save/load MiniProfiler results. Creates needed tables. Run this once on your database. Works in sql server and sqlite (with documented removals). TODO: add indexes Returns a new . Stores 'profiler' to dbo.MiniProfilers under 'id'; stores all child Timings and SqlTimings to their respective tables. Saves parameter Timing to the dbo.MiniProfilerTimings table. Saves parameter SqlTiming to the dbo.MiniProfilerSqlTimings table. Saves any SqlTimingParameters used in the profiled SqlTiming to the dbo.MiniProfilerSqlTimingParameters table. Loads the MiniProfiler identifed by 'id' from the database. Returns a connection to Sql Server. An individual profiling step that can contain child steps. Rebuilds all the parent timings on deserialization calls Offset from parent MiniProfiler's creation that this Timing was created. Creates a new Timing named 'name' in the 'profiler's session, with 'parent' as this Timing's immediate ancestor. Obsolete - used for serialization. Returns this Timing's Name. Adds arbitrary string 'value' under 'key', allowing custom properties to be stored in this Timing step. Completes this Timing's duration and sets the MiniProfiler's Head up one level. Add the parameter 'timing' to this Timing's Children collection. Used outside this assembly for custom deserialization when creating an implementation. Adds the parameter 'sqlTiming' to this Timing's SqlTimings collection. A sql statement profiling that was executed in this Timing step. Used outside this assembly for custom deserialization when creating an implementation. Unique identifer for this timing; set during construction. Text displayed when this Timing is rendered. How long this Timing step took in ms; includes any Timings' durations. The offset from the start of profiling. All sub-steps that occur within this Timing step. Add new children through Stores arbitrary key/value strings on this Timing step. Add new tuples through . Any queries that occurred during this Timing step. Needed for database deserialization and JSON serialization. Which Timing this Timing is under - the duration that this step takes will be added to its parent's duration. This will be null for the root (initial) Timing. Gets the ellapsed milliseconds in this step without any children's durations. Gets the aggregate ellapsed milliseconds of all SqlTimings executed in this Timing, excluding Children Timings. Returns true when this is less than the configured , by default 2.0 ms. Reference to the containing profiler, allowing this Timing to affect the Head and get Stopwatch readings. Returns true when this Timing has inner Timing steps. Returns true if this Timing step collected sql execution timings. Returns true if any s executed in this step are detected as duplicate statements. Returns true when this Timing is the first one created in a MiniProfiler session. How far away this Timing is from the Profiler's Root. How many sql data readers were executed in this Timing step. How many sql scalar queries were executed in this Timing step. How many sql non-query statements were executed in this Timing step. Categories of sql statements. Unknown DML statements that alter database state, e.g. INSERT, UPDATE Statements that return a single record Statements that iterate over a result set Contains helper code to time sql statements. Returns a new SqlProfiler to be used in the 'profiler' session. Tracks when 'command' is started. Finishes profiling for 'command', recording durations. Called when 'reader' finishes its iterations and is closed. The profiling session this SqlProfiler is part of. Helper methods that allow operation on SqlProfilers, regardless of their instantiation. Tracks when 'command' is started. Finishes profiling for 'command', recording durations. Called when 'reader' finishes its iterations and is closed. Understands how to route and respond to MiniProfiler UI urls. Returns this to handle . Returns either includes' css/javascript or results' html. Handles rendering static content files. Handles rendering a previous MiniProfiler session, identified by its "?id=GUID" on the query. Embedded resource contents keyed by filename. Helper method that sets a proper 404 response code. Try to keep everything static so we can easily be reused. Formats SQL server queries with a DECLARE up top for parameter values Formats the SQL in a SQL-Server friendly way, with DECLARE statements for the parameters up top. The SqlTiming to format A formatted SQL string Common extension methods to use only in this project Answers true if this String is either null or empty. Answers true if this String is neither null or empty. Removes trailing / characters from a path and leaves just one Removes any leading / characters from a path Removes any leading / characters from a path Extension mechanism for additional services; requested service provider or null. Wraps a database connection, allowing sql execution timings to be collected when a session is started. Returns a new that wraps , providing query execution profiling. Your provider-specific flavor of connection, e.g. SqlConnection, OracleConnection Returns a new that wraps , providing query execution profiling. Your provider-specific flavor of connection, e.g. SqlConnection, OracleConnection The currently started or null. Returns a new that wraps , providing query execution profiling. If profiler is null, no profiling will occur. Your provider-specific flavor of connection, e.g. SqlConnection, OracleConnection The currently started or null. Information about a DbParameter used in the sql statement profiled by SqlTiming. Which SqlTiming this Parameter was executed with. Parameter name, e.g. "@routeName" The value submitted to the database. System.Data.DbType, e.g. "String", "Bit" How large the type is, e.g. for string, size could be 4000 Profiles a single sql execution. Creates a new SqlTiming to profile 'command'. Obsolete - used for serialization. Called when command execution is finished to determine this SqlTiming's duration. Called when database reader is closed, ending profiling for SqlTimings. To help with display, put some space around sammiched commas Unique identifier for this SqlTiming. Category of sql statement executed. The sql that was executed. The sql that was executed. The command string with special formatting applied based on MiniProfiler.Settings.SqlFormatter Roughly where in the calling code that this sql was executed. Offset from main MiniProfiler start that this sql began. How long this sql statement took to execute. When executing readers, how long it took to come back initially from the database, before all records are fetched and reader is closed. Stores any parameter names and values used by the profiled DbCommand. Id of the Timing this statement was executed in. Needed for database deserialization. The Timing step that this sql execution occurred in. True when other identical sql statements have been executed during this MiniProfiler session. Gets part of a stack trace containing only methods we care about. Contains the default list of full type names we don't want in any stack trace snippets. Understands how to store a to the with absolute expiration. The string that prefixes all keys that MiniProfilers are saved under, e.g. "mini-profiler-ecfb0050-7ce8-4bf1-bf82-2cb38e90e31e". Returns a new HttpRuntimeCacheStorage class that will cache MiniProfilers for the specified duration. Saves to the HttpRuntime.Cache under a key concated with and . Returns the originally-stored How long to cache each for (i.e. the absolute expiration parameter of ) If the underlying command supports BindByName, this sets/clears the underlying implementation accordingly. This is required to support OracleCommand from dapper-dot-net