ASP Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.11

ASP Performance

Part:   1  2 

ASP Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

hyBook - Guestbook Application

Using MS Access Databases

ActiveX Data Object (ADO)

Controlling Response Header Lines

Microsoft Scripting Runtime DLL

Using Cookies

ASP Sessions

ASP Objects

Microsoft Script Debugger

Internet Information Services (IIS)

... Table of Contents

(Continued from previous part...)

Response Time of "Hello" Page

The next area I want test is total response time of ASP pages. To do this, I wrote the following Java program. This program is doing a single HTTP request to a specifield Web page, and repeating this for many times.

/**
 * HttpResponseTest.java
 * Copyright (c) 2002 by Dr. Herong Yang. All rights reserved.
 */
import java.io.*;
import java.net.*;
public class HttpResponseTest {
   public static void main(String[] args) {
      int numberOfTests = 1;
      if (args.length > 0) numberOfTests 
         = Integer.valueOf(args[0]).intValue();
      long t1 = System.currentTimeMillis();
      String result = "";
      for (int nTest=1; nTest<=numberOfTests; nTest++) {
         result = test(args);
      }
      long t2 = System.currentTimeMillis();
      long t = t2 - t1;
      PrintStream out = System.out;
      out.println("Performace Information:");
      out.println("   Number of tests = " + numberOfTests);
      out.println("   Time = " + (t/1000) + " seconds.");
      out.println("Rerulst of Last Test:");
      out.println(result);
   }
   public static String test(String[] args) {
      String path = "/index.html";
      int port = 80;
      String host = "localhost";
      if (args.length > 1) path = args[1];
      if (args.length > 2) port
         = Integer.valueOf(args[2]).intValue();
      if (args.length > 3) host = args[3];
      String result = "";
      try {
         Socket c = new Socket(host,port);
         BufferedWriter w = new BufferedWriter(new OutputStreamWriter(
            c.getOutputStream()));
         BufferedReader r = new BufferedReader(new InputStreamReader(
            c.getInputStream()));
         String m = "GET "+path;
         w.write(m,0,m.length());
         w.newLine();
         w.flush();
         while ((m=r.readLine())!= null) {
            result = result + m + "\n";
         }
         w.close();
         r.close();
         c.close();
      } catch (IOException e) {
         System.err.println(e.toString());
      }
      return result;      
   }
}

Now compile this program and try it with the following "Hello" ASP page, hello.asp:

<%@ language="vbscript"%>
<html><body>
<%
response.write("Hello world!")
%>
</body></html>

you will get something similar to this:

\local\j2sdk1.4.1_01\bin\java -cp . HttpResponseTest 1 /asp/hello.asp
Performace Information:
   Number of tests = 1
   Time = 0 seconds.
Rerulst of Last Test:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 24 Dec 2002 02:47:31 GMT
Connection: Keep-Alive
Content-Length: 38
Content-Type: text/html
Set-Cookie: ASPSESSIONIDGGGQQWLY=BJINNIGBFMBPMNHNNCJFDJLG; path=/
Cache-control: private

<html><body>Hello world!</body></html>

I repeated the tests by changes the controlling parameters. The following table shows the results comparing with similar tests I did with other technologies:

        Number     Debug   Time
Cases   of Tests   Mode    (Sec)   Note
1.      1000       No      2       Static text with IIS 5.0
2.      2000       No      4       Static text with IIS 5.0
3.      1000       No      6       ASP page with IIS 5.0
4.      2000       No      11      ASP page with IIS 5.0
5.      1000       ?       7       Static text with Tomcat 4.1.18
6.      2000       ?       15      Static text with Tomcat 4.1.18
7.      1000       ?       8       JSP page with Tomcat 4.1.18
8.      2000       ?       16      JSP page with Tomcat 4.1.18

Conclusion:

  • So the performance cost of writing text through ASP statements is 2 times slower than the static pages.
  • Tomcat is 3 times slower than IIS when serving static pages.
  • Tomcat is also slower than IIS when serving dynamic text.

Part:   1  2 

Dr. Herong Yang, updated in 2002
ASP Tutorials - Herong's Tutorial Notes - ASP Performance