5

I'm thinking about using ASP.NET in a new project I'm starting and I'm wondering if it's faster than classic ASP. I've been using classic for years, and never ran into any problems, but I really want to pick the fastest out of the three.

Thanks for your help!

6 Answers 6

8

Fastest to run? Fastest to develop a site with? Fastest to solve problems when they occur? Fastest to train new developers up on?

All will run fast enough if well written. All will run dog slow if not. I think you need to consider how valid your objective here is.

1
  • 1
    Sorry, I should have been more clear, I meant fastest to run.
    – will
    Commented Nov 25, 2009 at 20:09
5

I was arguing about this topic with one of my friends. He believes that Classic ASP is much faster. So I googled and found this old question and nothing else. So I decided to run a speed test comparing ASP.NET and Classic ASP and the results are amazingly unbelievable!

I tested in an equal environment with these two cases:

1- using ADODB to query an SQL database table with more than 500.000 rows. with both asp.net and classic asp. It takes 133000ms for ASP.NET It takes 5000ms for Classic ASP

The ASP.NET code:

var conn = new ADODB.Connection();
conn.Open(@"Driver={SQL Server};Server=.\sql2008;Database=Db;User Id=sa;Password=pwd");
ADODB.Recordset rs = new ADODB.Recordset();
var sql = "SELECT * From tRep";
rs.Open(sql, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic, 0);
    while (rs.EOF == false)
        rs.MoveNext();

Classic ASP code:

Set dbconn = CreateObject("ADODB.Connection")
dbconn.open "Driver={SQL Server};Server=.\sql2008;Database=Db;User Id=sa;Password=pwd"
set rs=dbconn.execute("SELECT * From trep") 
while not rs.eof
    rs.movenext
wend
dbconn.Close

2- My second test was same as the first one, using ADO.NET in both ASP.NET and Classic ASP(using a ComVisible .Net Assembly)

It takes 2155ms for ASP.NET to query the database and 1745ms for Classic ASP Here are my codes:

//ASP.NET Codes:
var i = 0;
            var result = "";
            double av = 0;
            var runs = 50;
            for (var j = 0; j < runs; j++)
            {
                var t1 = DateTime.Now;
                var CS = @"data source=.\sql2008;initial catalog=Db;user id=sa;password=pwd;multipleactiveresultsets=True;";
                var Query = "SELECT * From trep";
                using (var conn = new SqlConnection(CS))
                {
                    conn.Open();
                    using (var cmd = new SqlCommand(Query, conn))
                    {
                        using (var dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            if (dr.HasRows)
                            {

                                while (dr.Read())
                                {
                                    var x = dr[0];
                                    i++;
                                }
                            }
                        }
                    }
                }
                var t2 = DateTime.Now;
                av = av + (t2 - t1).TotalMilliseconds;
                result += "\r\nRun " + (j + 1) + ": " + (t2 - t1).TotalMilliseconds;
            }
            result += result + "\r\nAVG=" + (av / runs / 1000);

'Classic ASP Codes:

Set db = CreateObject("ADONET.AdoDotNet")
runs=50
av=0
for i=1 to runs
    t1=timer()
    xx= db.ExecuteQuery("SELECT * From trep","data source=.\sql2008;initial catalog=Db;user id=sa;password=pwd;multipleactiveresultsets=True")
    t2=timer()
    response.write("Run "&i&" Total Time(sec):"&(t2-t1)&"<br>")
    av=av+t2-t1
next
g=av/runs
response.write("avg:"&g&"<br>")

And the ComVisible ADONET.AdoDotNet class is:

[ComVisible(true)]
    public class AdoDotNet
    {
        [ComVisible(true)]
        public int ExecuteQuery(string Query,string CS)
        {
            var i = 0;
            //var ds = new DataSet();
            using (var conn=new SqlConnection(CS))
            {
                conn.Open();
                using(var cmd = new SqlCommand(Query, conn))
                {
                    using (var dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        if (dr.HasRows)
                        {

                            while (dr.Read())
                            {
                                var x = dr[0];
                                i++;
                            }
                        }
                    }
                }
            }
            return i;
        }
    }

Interesting point is the more you increase the runs, it take more time for ASP.NET to execute the codes!

2
  • 1
    That is indeed incredible. Did you compile the ASPX code before test?
    – Combinatix
    Commented Apr 13, 2021 at 17:46
  • 1
    yes it was precompiled
    – Hossein
    Commented Apr 14, 2021 at 12:45
3

As an old Classic ASP'er, I have to say that ASP.Net is the way to go.
I did favor Classic over .Net initially, but not when 2.0 came out. .Net is compiled and the frameworks are extensive. It's hard to stick with a decade old web platform.

2

For one .Net is a compiled and VBScript is, well, a script language. Just the fact that .Net is compiled and classic is not gives .Net a huge advantage.

PHP which is a script language and not compiled, is 10 times slower than .Net...

2
  • 3
    Do you have some facts/link/etc to back up the 10x faster than PHP assertion? Commented Nov 30, 2009 at 15:39
  • 1
    @mgroves - Yes I do. Jeff Atwood mentioned it in one of the stackoverflow podcasts. He also blogged/tweeted about it. Link: 25hoursaday.com/weblog/2009/10/29/…. Commented Nov 30, 2009 at 16:44
2

If you are talking about requests per second, you might want to look here:

http://msdn.microsoft.com/en-us/library/ms973813.aspx

Microsoft states asp.net is significantly faster than asp.

2

Unless you have a SuperSite (like StackOverflow) your main performance problems are:

  • Database
  • Bandwidth

And none of those are related to ASP Classic or .Net

But, do pick ASP.Net because:

  • Great and modern tools
  • MVC is great
  • Global.asax catch all Application_Error gives you peace of mind.
  • Master pages
  • Membership built in
  • Server controls
  • Full and real OOP language
  • Easier cache management
  • LINQ

Not the answer you're looking for? Browse other questions tagged or ask your own question.