Created
October 19, 2011 15:19
-
-
Save mayuki/1298603 to your computer and use it in GitHub Desktop.
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
@DateTime.Now.Ticks |
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
@helper TestHelper() { | |
{<text>@DateTime.Now.Ticks</text>} | |
} |
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.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace MvcApplication1.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
// | |
// GET: /Home/ | |
//[OutputCache(Duration = 10)] | |
public ActionResult Index() | |
{ | |
return View(); | |
} | |
[ChildActionOnly] | |
public ActionResult TestPartial() | |
{ | |
return PartialView("_TestPartial"); | |
} | |
[OutputCache(Duration = 60)] | |
[ChildActionOnly] | |
public ActionResult TestPartialWithCache() | |
{ | |
return PartialView("_TestPartial"); | |
} | |
} | |
} |
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.Diagnostics | |
@{ | |
ViewBag.Title = "Index"; | |
} | |
@helper TestHelper() { | |
{<text>@DateTime.Now.Ticks</text>} | |
} | |
<h2>Index</h2> | |
<h2>RenderPartial</h2> | |
<!-- | |
@{var t1 = Stopwatch.StartNew();} | |
@for (var i = 0; i < 1000; i++) | |
{ | |
Html.RenderPartial("_TestPartial"); | |
} | |
@{t1.Stop();} | |
--> | |
<p>@t1.Elapsed @(t1.ElapsedMilliseconds / 1000.0) ms/call</p> | |
<h2>RenderAction</h2> | |
<!-- | |
@{var t2 = Stopwatch.StartNew();} | |
@for (var i = 0; i < 1000; i++) | |
{ | |
Html.RenderAction("TestPartial"); | |
} | |
@{t2.Stop();} | |
--> | |
<p>@t2.Elapsed @(t2.ElapsedMilliseconds / 1000.0) ms/call</p> | |
<h2>RenderAction w/ OutputCache(Duration = 10)</h2> | |
<!-- | |
@{var t3 = Stopwatch.StartNew();} | |
@for (var i = 0; i < 1000; i++) | |
{ | |
Html.RenderAction("TestPartialWithCache"); | |
} | |
@{t3.Stop();} | |
--> | |
<p>@t3.Elapsed @(t3.ElapsedMilliseconds / 1000.0) ms/call</p> | |
<h2>Inline</h2> | |
<!-- | |
@{var t4 = Stopwatch.StartNew();} | |
@for (var i = 0; i < 1000; i++) | |
{ | |
{<text>@DateTime.Now.Ticks</text>} | |
} | |
@{t4.Stop();} | |
--> | |
<p>@t4.Elapsed @(t4.ElapsedMilliseconds/1000.0) ms/call</p> | |
<h2>Helper</h2> | |
<!-- | |
@{var t5 = Stopwatch.StartNew();} | |
@for (var i = 0; i < 1000; i++) | |
{ | |
@TestHelper() | |
} | |
@{t5.Stop();} | |
--> | |
<p>@t5.Elapsed @(t5.ElapsedMilliseconds/1000.0) ms/call</p> | |
<h2>Helper (App_Code)</h2> | |
<!-- | |
@{var t6 = Stopwatch.StartNew();} | |
@for (var i = 0; i < 1000; i++) | |
{ | |
@ExternalHelper.TestHelper() | |
} | |
@{t6.Stop();} | |
--> | |
<p>@t6.Elapsed @(t6.ElapsedMilliseconds/1000.0) ms/call</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment