DLL object/class with methods or include with functions ?
ActiveX RegEdit.   ActiveX User account Manager   Pure-ASP Upload
Export MDB/DBF from ASP   Active LogFile   WebChecker   ActiveX/ASP Multi Dictionary object
 See 
 also 
 IISTracer, real-time IIS monitor and logging tool.
 Huge ASP file upload with progress bar. 



Do you like this article?
Please, rate it
and write review!
Rated:
by Aspin.com users
What do you think?
 Top messages
 22.3.2003 19:18:41 
 Read and write SQL image data, store binary file to sql table. (nbsp;WSHDatabaseConversionVBScript)
 4.5.2002 9:16:43 
 Send an email from ASP (WSH) using VBSscript, CDONTS and Outlook. (nbsp;ASP / ASP.NetWSHVBScriptEmail)
 12.6.2003 9:14:29 
 Download multiple files in one http request (nbsp;File & data transferVBScript)

 DLL object/class with methods or include with functions ? 

 Areas>ASP / ASP.Net>Performance tests
      Large include with tenth of functions and constants or OLE object ? That is the question.

Performance test configuration

- P200, 128MB RAM
- Win NT 4.0 SP5
- IIS 4
- VBS v.5

Performance

      There are some performance tests that says which of object or include is better. First is the time of a call of a function or object method.
Processor time taken by one function/method call.
 function/method source  Description  JS time 
 [mics] 
 VBS time 
 [mics] 
 VB5 DLL  Call the method in typed VB5 - same for 1st and 100th metod    3 
 VB5 DLL  Call of the 1st method  92  86 
 VB5 DLL  Call of the 50th method  332  322 
 VB5 DLL  Call of the 100th method  589  580 
 VB5 DLL  Call of the default method    40 
 C++ DLL  Call of the 1st method  70  63 
 C++ DLL  Call of the 50th method  74  66 
 C++ DLL  Call of the 100th method  77  70 
 C++ DLL  Call of the default method    28 
 ASP class  same for 1st and 100th metod    45 
 ASP class  Call of the default method    36 
 ASP function  same for 1st and 1000th function  28  16 

      Call of the ASP function takes minimum of the processor time (16 mics in VBS). Processor time of VBS-Function/VBS-class method call does not depend on number of functions.
      The dependence is minimal also for object in DLL created by C++ (7/100 mics per method). Problems are with object from VB5 DLL - the method call takes 86 mics and the time gains 5 mics for each next method call.

      The table shows a main problem of VBS script against VB for application code - VBS objects, functions, properties, methods and variables are not typed. The object interface is resolved on run-time and the resulution takes most of the processor time for call of the function/method (call of typed method takes 3 mics, best call of untyped function takes 16 mics (5 times more) and untyped method takes 40mics (10 times more).
      The table also shows that JScript takes a little more time than VBScript for the same operation.

      Second time to decide between object and include is time taken to create object from library:
Processor time to create object.
 function/method source  Description  Note  Kernel+User 
 Time [mics] 5)
 VB5 DLL  Server.CreateObject  With onstartpage  2 614.00 
 VB5 DLL  Server.CreateObject  Without onstartpage  2 412.00 
 VB5 DLL  CreateObject    571.00 
 C++ DLL  Server.CreateObject  With onstartpage  2 500.00 
 C++ DLL  Server.CreateObject  Without onstartpage  2 100.00 
 C++ DLL  CreateObject    366.00 

      Create object with OnStartPage function takes 2.6 ms (2.5 ms for C++). This is main problem of using object instead of include.
      You can use CreateObject function (instead CreateObject method of Server) to create objects that does not access scripting context.

      Next value to decide is time to call some of ASP function and methods:
Time taken by same code in VB/VBS/JS.
 VB Code  VBS Time 
 [mics] 
 JS Time 
 [mics]  
 VB5 Time 
 [mics]  
 Application("A2"), 0items  35  54  7 
 Application("A4"), 1000items  42  65  15 
 request.querystring  124    8 
 request.querystring("A")  176  161  47 
 request.querystring.Item("A")  210  205  47 
 request.servervariables("HTTP_REFERER")  177  175  55 
 request.ServerVariables("REMOTE_ADDR")  205  175  74 
 request.servervariables("X")  224  226  95 
 request.servervariables("HTTP_COOKIE")  318    109 
 request.cookies("AAA")  165  160  47 
 request.totalbytes  61  61  3 
 A = X & "AAAA"  4.6    1.7 
 A = "" & Now()  40.7    29.3 
 D = Now  10.8    9.8 
 A = FormatNumber(5.5,2)  17.6     
 A = Format(5.5, "0.00")      52.4 
 A = Left(X,2)  5.8    1.7 
 D = InStr(X, "bb")  4.4    1.4 
 Call sub  7.4    1.4 
 CreateObject("ADODB.Connection")  1110    471 
 CreateObject("ADODB.Recordset")  751    83 
 CreateObject("Scripting.Dictionary")  590    257 
 CreateObject("Scripting.FileSystemObject")  350    27 

      The table also shows the problem with typed/nontyped objects. Also default ASP objects (Application, Request, ...) are NOT typed. Call of its methods in VBS takes 20 times more processor time than the call in VB5.
      The time of call of a default method/property (Application("A2") - 35mics) is similar to previous table (C++ DLL 28mics, VB5DLL 40 mics). The times for non-default are also similar (request.totalbytes, 61mics vs 63 mics on C++ DLL).

Memory


      The big advance of code in C++/VB DLL is that the code resides only one in memory.
      ASP include resides in memory each time is included. Each one byte of source code takes up to 3 bytes in memory. If you have 100kB ASP include file and the file is included to 100 ASP pages, the pages takes :
100kB * 3 * 100 = 30 MB of memory.

Results.


      Decision between includes and VB/C++ object is not simple. The decision depends on volume of source code, number of functions, number of function calls and number of scripts that the function is included.

The main disadvantages of ASP includes are :
1. Code resides in memory each time
2. All operations with variables, functions, objects and constants in ASP/VBS include are much time slower than same operations in VB5 (or C++).

The main disadvantages of using same code as methods of compiled object are :
1. Call of the method takes more time than call of ASP function (The problem is worse in VB5 DLL)
2. Create the object takes also many time


5) Kernel+User time - times of calling thread in [ms]
   The time has only relative meaning - because the time was on the pure configuration (P200/128M), the real times will be better.
 
 

See also for 'DLL object/class with methods or include with functions ?' article:

     ASP/VBS database performance test and comparison. ADO, DAO, RDO, MDB, SQL, OLEDB and ODBC comparison, performance test of objects that can be used for database access on server-side in ASP.

If you like this page, please include next link on your pages:
<A
 Href="http://www.motobit.com/tips/detpg_DLLinclude/"
 Title="Time tests to make decision between
  ASP include and VB/C++ object
  in ASP/VBS."
>DLL object/class with methods or include with functions ?</A>

     IISTracer - IIS ISAPI real-time monitor IISTracer is a real-time monitoring tool for Microsoft IIS, which will show/log you what is happenning on IIS server right now. It let's you reveal problems with long-running scripts (.asp, .cgi, cfm...), hang-up states and low resource situations and lets you stop long-running requests (uploads/downloads).      ActiveX User account Manager - Set of simple objects for creating, deleting, and managing user accounts, groups, servers and domains in the Windows NT environment.
     Active log file - Hi-performance text file logging for ASP/VBS/VBA applications. Lets you create daily/weekly/monthly log files with variable number of logged values and extra timing and performance info.      ActiveX windows registry editor - Intuitive, easy to use COM interface to windows registry. Set of classes to read/enumerate/modify windows registry keys and values from ASP, VBS and T-SQL.
     ActiveX/ASP Multi Dictionary object - Free-threaded hi-speed dictionary algorithm with unique/nonunique keys (map/multimap). Connect to another dictionary object in the same process. Lock and Unlock methods to synchronize tasks (application scope). Share ASP Application/Session objects.      Export DBF/MDB from ASP - Conversion from recordset to MDB/DBF. Direct binary output of MDB or DBF files from ASP pages with one row of code.
     Pure-ASP upload - lets you upload files using Pure ASP VBS code (using multipart/form-data and input type=file).      ByteArray - Works with safearray binary data (VT_UI1 | VT_ARRAY) - save/restore binary data from disk, find, work with code pages, convert to string/hexstring(SQL).
     WebChecker - Checks http, https, ftp and gopher internet connections in regular intervals. Lets you monitor web site functionality (uptime). Enables restart or notification on problems.      HTTPLog ISAPI filter - Lets you log incomming/outgoing http header and document data to separate files. Monitor of IIS service input/output.

© 1996 – 2010 Antonin Foller, PSTRUH Software, e-mail help@pstruh.cz