ASP.NET Performance through early binding

Microsoft said, ASP.NET applications contain 40 to 70 percent less code than ASP `applications`. My little test shows that it’s true, ASP.NET is really faster. However, an exact statement on speed is difficult because it’s depending on many factors.

The point of success isn’t the compiling but the early binding. That can be shown in an easy loop. I’ve used a Dual AMD Opteron, 2GHZ, 4GB RAM on Windows 2003 Server / IIS 6.0 for that test, here’s the code:

In ASP:

<%
Dim b, a, start, end, count
count = 50000000
Response.Write("Loops: " & count & "<hr>")
start = now
for a = 1 to count
b = b + a
next
end = now
Response.Write("Start: " & start & "<br>")
Response.Write("End: " & end & "<br>")
Response.Write("Execution length: " & DateDiff("s",start,end))
%>

In ASP.NET 2.0 with late binding:

private void Page_Load(object sender, System.EventArgs e)
{
object b = null;
object a = null;
object start = null;
object end = null;
object count = null;
count = 50000000;
Response.Write("Loops: " + count.ToString() + "<hr");
start = DateTime.Now;
object tempFor1 = ;
for (a = 1; a <= count; a++)
{
b = b + a;
}
end = DateTime.Now;
Response.Write("Start: " + start.ToString() + "<br>");
Response.Write("End: " + end.ToString() + "<br>");
Response.Write("Execution length:
 " +  Microsoft.VisualBasic.DateAndTime.DateDiff("s", start,
 end, Microsoft.VisualBasic.FirstDayOfWeek.Sunday,
 Microsoft.VisualBasic.FirstWeekOfYear.Jan1));
}

And now in ASP.NET 2.0 with early binding:

Same like above but:
Int64 b, Int64 a, DateTime start;
DateTime end;
Int64 count;

Here are the results:

  • The ASP Code: 26 seconds
  • The ASP.NET 2.0 Code with late binding: 16 seconds
  • The ASP.NET 2.0 Code with early binding: < 1 second!

The result speaks for itself.

kick it on DotNetKicks.com

5 comments ↓

#1 vikram on 10.24.06 at 2:16 pm

Good point made

#2 Luca on 10.24.06 at 5:41 pm

(duh! blog ate my comment)

The result of _that_ loop is constant and can be precomputed. In this case early-binding helps so much because the JIT has enough information to optimize it away entirely.

#3 Adi on 10.25.06 at 1:02 pm

Good point!

#4 Izzmo on 11.13.06 at 9:02 pm

Wow, that’s amazing how the bindings made that much of a difference.

Cool, thanks for pointing that out.

#5 vasanthi on 09.17.08 at 9:45 am

WoW!!. Keep it UP..

Leave a Comment