English 中文(简体)
Anyone have benchmarks / speed tests comparing Classic ASP vs ASP.NET 2.0 or 3.5? [closed]
原标题:

Closed. This question needs to be more focused. It is not currently accepting answers.


Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 3 years ago.

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!

最佳回答

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...

问题回答

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.

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 += "
Run " + (j + 1) + ": " + (t2 - t1).TotalMilliseconds;
            }
            result += result + "
AVG=" + (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!

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.

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

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.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签