������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
������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�|
|�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.|
|�VB5 DLL�||�Server.CreateObject�||�With onstartpage�||�2�614.00�|
|�VB5 DLL�||�Server.CreateObject�||�Without onstartpage�||�2�412.00�|
|�C++ DLL�||�Server.CreateObject�||�With onstartpage�||�2�500.00�|
|�C++ DLL�||�Server.CreateObject�||�Without onstartpage�||�2�100.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�|
|�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�|
������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).
������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.
������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.
for 'DLL object/class with methods or include with functions ?' articleASP/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.
Copyright and use this code
The source code on this page and other samples at https://www.motobit.com/tips/
are a free code, you can use it as you want: copy it, modify it, use it in your products, ...
If you use this code, please:
1. Leave the author note in the source.
2. Link this sample from you page.
Title="Time tests to make decision between
ASP include and VB/C++ object
>DLL object/class with methods or include with functions ?</A>