Skip to content

Instantly share code, notes, and snippets.

@JesseBuesking
Created May 30, 2012 00:29
Show Gist options
  • Save JesseBuesking/2831681 to your computer and use it in GitHub Desktop.
Save JesseBuesking/2831681 to your computer and use it in GitHub Desktop.
MiniProfiler Client Timing Persistent Storage
// SqlServerStorage.cs
// ...
if (t.HasChildren) // line 187 of the original file
{
foreach (var child in t.Children)
{
SaveTiming(conn, profiler, child);
}
}
if (profiler.ClientTimings != null && profiler.ClientTimings.Timings != null && profiler.ClientTimings.Timings.Count > 0)
{
foreach (var client in profiler.ClientTimings.Timings)
{
SaveClientTiming(conn, profiler, client);
}
}
// ...
/// <summary>
/// Saves Client Timing to the dbo.MiniProfilerClientTimings table.
/// </summary>
protected void SaveClientTiming(DbConnection conn, MiniProfiler profiler, ClientTimings.ClientTiming client)
{
// I'm thinking that since there's no id on a client timing, the database table
// dbo.MiniProfilerClientTimings will use both the MiniProfiler Id and ClientTiming Name
// together to form the primary key... haven't actually tried this yet.
const string sql =
@"INSERT INTO miniprofilerclienttimings
(miniprofilerid,
name,
start,
duration
)
VALUES (@MiniProfilerId,
@Name,
@Start,
@Duration
)";
conn.Execute(sql, new
{
MiniProfilerId = profiler.Id,
Name = client.Name,
Start = client.Start,
Duration = client.Duration
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment