Created
July 9, 2012 12:15
-
-
Save nootn/3076142 to your computer and use it in GitHub Desktop.
MiniProfiler.Windows Samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (StackExchange.Profiling.MiniProfiler.Current.Step("Call Methods")) | |
{ | |
//Some work to be done here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PM> Install-Package MiniProfiler.Windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (StackExchange.Profiling.MiniProfiler.Current.Step("Call Methods")) | |
{ | |
//Do some work, E.g. call methods.. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using MiniProfiler.Windows; | |
using StackExchange.Profiling; | |
namespace ConsoleApplicationSimpleExample | |
{ | |
internal class Program | |
{ | |
private static void Main() | |
{ | |
//Start profiling | |
ConsoleProfiling.Start(); | |
Console.WriteLine("Starting to call methods.."); | |
using (StackExchange.Profiling.MiniProfiler.Current.Step("Call Methods")) | |
{ | |
DoTheQuickWork(); | |
DoTheSlowWork(); | |
} | |
//Stop profiling and show results | |
Console.WriteLine(ConsoleProfiling.StopAndGetConsoleFriendlyOutputStringWithSqlTimings()); | |
//Allow viewing of results | |
Console.WriteLine("... press 'Enter' to exit process ..."); | |
Console.ReadLine(); | |
} | |
private static void DoTheQuickWork() | |
{ | |
using (StackExchange.Profiling.MiniProfiler.Current.Step("DoTheQuickWork")) | |
{ | |
Thread.Sleep(100); | |
Console.WriteLine(" ... done quick work ... "); | |
} | |
} | |
private static void DoTheSlowWork() | |
{ | |
using (StackExchange.Profiling.MiniProfiler.Current.Step("DoTheSlowWork")) | |
{ | |
Thread.Sleep(5000); | |
Console.WriteLine(" ... done slow work ... "); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConsoleProfiling.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var friendlyString = ConsoleProfiling.StopAndGetConsoleFriendlyOutputStringWithSqlTimings(); | |
Console.WriteLine(friendlyString); | |
Debug.WriteLine(friendlyString); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = ConsoleProfiling.StopAndGetProfiler(); | |
//You can now check the MiniProfiler result, such as these useful properties: | |
result.HasSqlTimings; | |
result.DurationMilliseconds; | |
result.DurationMillisecondsInSql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment