本文整理汇总了C#中StackExchange.Profiling.MiniProfiler.Step方法的典型用法代码示例。如果您正苦于以下问题:C# MiniProfiler.Step方法的具体用法?C# MiniProfiler.Step怎么用?C# MiniProfiler.Step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StackExchange.Profiling.MiniProfiler
的用法示例。
在下文中一共展示了MiniProfiler.Step方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpsertRouteHit
private void UpsertRouteHit(ActionDescriptor actionDesc, MiniProfiler profiler)
{
var routeName = actionDesc.ControllerDescriptor.ControllerName + "/" + actionDesc.ActionName;
using (var conn = GetConnection(profiler))
{
var param = new { routeName = routeName };
using (profiler.Step("Insert RouteHits"))
{
conn.Execute("insert or ignore into RouteHits (RouteName, HitCount) values (@routeName, 0)", param);
}
using (profiler.Step("Update RouteHits"))
{
// let's put some whitespace in this query to demonstrate formatting
conn.Execute(
@"update RouteHits
set HitCount = HitCount + 1
where RouteName = @routeName", param);
}
}
}
示例2: GetConnection
public static DbConnection GetConnection(MiniProfiler profiler = null)
{
using (profiler.Step("GetOpenConnection"))
{
DbConnection cnn = new System.Data.SQLite.SQLiteConnection(MvcApplication.ConnectionString);
// to get profiling times, we have to wrap whatever connection we're using in a ProfiledDbConnection
// when MiniProfiler.Current is null, this connection will not record any database timings
if (MiniProfiler.Current != null)
{
cnn = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current);
}
cnn.Open();
return cnn;
}
}
示例3: RecursiveMethod
private void RecursiveMethod(ref int i, DbConnection conn, MiniProfiler profiler)
{
Thread.Sleep(5); // ensure we show up in the profiler
if (i >= 10) return;
using (profiler.Step("Nested call " + i))
{
// run some meaningless queries to illustrate formatting
conn.Query(
@"select *
from MiniProfilers
where Name like @name
or Name = @name
or DurationMilliseconds >= @duration
or HasSqlTimings = @hasSqlTimings
or Started > @yesterday ", new
{
name = "Home/Index",
duration = 100.5,
hasSqlTimings = true,
yesterday = DateTime.UtcNow.AddDays(-1)
});
conn.Query(@"select RouteName, HitCount from RouteHits where HitCount < 100000000 or HitCount > 0 order by HitCount, RouteName -- this should hopefully wrap");
// massive query to test if max-height is properly removed from <pre> stylings
conn.Query(
@"select *
from (select RouteName,
HitCount
from RouteHits
where HitCount between 0 and 9
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 10 and 19
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 20 and 29
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 30 and 39
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 40 and 49
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 50 and 59
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 60 and 69
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 70 and 79
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 80 and 89
union all
select RouteName,
HitCount
from RouteHits
where HitCount between 90 and 99
union all
select RouteName,
HitCount
from RouteHits
where HitCount > 100)
order by RouteName");
using (profiler.Step("Incrementing a reference parameter named i")) // need a long title to test max-width
{
i++;
}
RecursiveMethod(ref i, conn, profiler);
}
}