本文整理匯總了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);
}
}