498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' border="0" alt="" width="31" height="11" src="http://images.myeducs.cn/files/uploadimg/20120312/144143347.gif" />
测试用例2:InlinePage.aspx
与测试用例1不同,测试用例2则完全不使用服务器控件。
页面代码:
- <%@ Page Language="C#" %>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>PagePerformanceTest http://www.cnblogs.com/fish-li/</title>
- </head>
- <body>
- <p>This is InlinePage.aspx</p>
- <% foreach( BlogInfo b in XmlDb.Blogs ) { %>
- <a href="<%= b.Href %>" target="_blank"><%= b.Title %></a><br />
- <% } %>
- <hr />
- <% foreach( BlogInfo b in XmlDb.Blogs ) { %>
- <a href="<%= b.Href %>" target="_blank"><%= b.Title %></a><br />
- <% } %>
- <hr />
- <% foreach( BlogInfo b in XmlDb.Blogs ) { %>
- <a href="<%= b.Href %>" target="_blank"><%= b.Title %></a><br />
- <% } %>
- <hr />
- <% foreach( BlogInfo b in XmlDb.Blogs ) { %>
- <a href="<%= b.Href %>" target="_blank"><%= b.Title %></a><br />
- <% } %>
- <hr />
- <% foreach( BlogInfo b in XmlDb.Blogs ) { %>
- <a href="<%= b.Href %>" target="_blank"><%= b.Title %></a><br />
- <% } %>
- <hr />
- </body>
- </html>
测试代码:
- [Action]
- public object Test2(string callTimes)
- {
- int count = 0;
- int.TryParse(callTimes, out count);
- if( count <= 0 )
- return count;
- HttpContext context = HttpContext.Current;
- // 先执行一次,排除编译时间
- string html = MyMVC.PageExecutor.Render(context, "/TestPage/InlinePage.aspx", null);
- Stopwatch watch = Stopwatch.StartNew();
- for( int i = 0; i < count; i++ )
- html = MyMVC.PageExecutor.Render(context, "/TestPage/InlinePage.aspx", null);
- watch.Stop();
- return watch.Elapsed.ToString();
- }
当