Upgraded DisposableTimer to wrap the profiler... now we should really just use DisposableTimer for all profiling.

This commit is contained in:
Shannon Deminick
2013-05-13 21:11:03 -10:00
parent b6f52bf782
commit 5890fe1849
10 changed files with 196 additions and 99 deletions

View File

@@ -7,7 +7,6 @@ namespace Umbraco.Core.Profiling
/// </summary>
internal interface IProfiler
{
/// <summary>
/// Render the UI to display the profiler
/// </summary>
@@ -18,7 +17,7 @@ namespace Umbraco.Core.Profiling
string Render();
/// <summary>
/// Profile a step
/// Profile an operation
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
@@ -26,7 +25,7 @@ namespace Umbraco.Core.Profiling
/// Use the 'using(' syntax
/// </remarks>
IDisposable Step(string name);
/// <summary>
/// Start the profiler
/// </summary>

View File

@@ -13,7 +13,23 @@ namespace Umbraco.Core.Profiling
/// <returns></returns>
internal static IDisposable Step<T>(this IProfiler profiler, string name)
{
return profiler.Step(string.Format(typeof(T).Name + ", " + name));
if (profiler == null) throw new ArgumentNullException("profiler");
return profiler.Step(typeof (T), name);
}
/// <summary>
/// Writes out a step prefixed with the type
/// </summary>
/// <param name="profiler"></param>
/// <param name="objectType"></param>
/// <param name="name"></param>
/// <returns></returns>
internal static IDisposable Step(this IProfiler profiler, Type objectType, string name)
{
if (profiler == null) throw new ArgumentNullException("profiler");
if (objectType == null) throw new ArgumentNullException("objectType");
if (name == null) throw new ArgumentNullException("name");
return profiler.Step(string.Format("[{0}] {1}", objectType.Name, name));
}
}
}

View File

@@ -33,5 +33,7 @@ namespace Umbraco.Core.Profiling
{
get { return Value; }
}
}
}