Database Code
  Home arrow Database Code arrow Timing and Benchmarking ASP Scripts by Rob...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE CODE

Timing and Benchmarking ASP Scripts by Robert Chartier
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 1
    2001-05-03

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The simplest way to time a script is to basically take a snapshot (now())of the current time before some processing, and then take a snapshot at the end of the processing. For example:
    0. <%
    1. Dim dtBefore, dtAfter
    2. dtBefore = now()
    3. For x = 0 to 1000
    4. a = a + 1000
    5. next
    6. dtAfter = now()
    7.
    8. response.write "Duration (seconds)"& dateDiff("s",dtAfter,dtBefore)
    9.
    10. %>


    What we would like to do is get access to a more finer scale of measurement. We can easily do this via COM. Below is the source for a class file that I threw together that uses the API call GetTickCount().

    Timer.cls Code Output
    0. 'GetTickCount Declaration
    1. Private Declare Function GetTickCount Lib "Kernel32" () As Long
    2. 'The GetTickCount function retrieves the number of
    3. 'milliseconds that have elapsed since the system was started.
    4. 'It is limited to the resolution of the system timer.
    5. 'http://msdn.microsoft.com/library/psdk/sysmgmt/time_8wz8.htm
    6.
    7.
    8. Dim aNames(50) As String
    9. Dim aTimes(50) As Long
    10. Dim maxTimes As Long
    11. Dim allNames As String
    12.
    13. Public Sub setTime(ByVal name As String)
    14. If InStr(allNames, name + ",") > 0 Then
    15. For x = 0 To maxTimes
    16. If aNames(x) = name Then
    17. aTimes(x) = GetTickCount()
    18. Exit For
    19. End If
    20. Next
    21. Else
    22. maxTimes = maxTimes + 1
    23. aNames(maxTimes) = name
    24. aTimes(maxTimes) = GetTickCount()
    25. allNames = allNames + name + ","
    26. End If
    27. End Sub
    28.
    29. Public Function getTime(ByVal name As String) As Long
    30. If InStr(allNames, name) > 0 Then
    31. For x = 0 To maxTimes
    32. If aNames(x) = name Then
    33. getTime = aTimes(x)
    34. Exit For
    35. End If
    36. Next
    37. Else
    38. getTime = 0
    39. End If
    40. End Function
    41.
    42. Public Function getNow() As Long
    43. getNow = GetTickCount()
    44. End Function
    45.
    46. Public Function formatTime(ByVal lTime1 As Long) As String
    47. 'parts borrowed from MSDN
    48.
    49. Dim hour As Integer, minute As Integer, second As Integer
    50. Dim raw
    51. raw = lTime1 \ 1000
    52. hour = raw \ 3600
    53. raw = raw - (hour * 3600)
    54. minute = raw \ 60
    55. raw = raw - (minute * 60)
    56. second = raw
    57. If minute < 10 Then
    58. If second < 10 Then
    59. sReturn = hour & ":0" & minute & ":0" & second
    60. Else
    61. sReturn = hour & ":0" & minute & ":" & second
    62. End If
    63. Else
    64. If second < 10 Then
    65. sReturn = hour & ":" & minute & ":0" & second
    66. Else
    67. sReturn = hour & ":" & minute & ":" & second
    68. End If
    69. End If
    70. formatTime = sReturn
    71. End Function

    Download Full Source here and compile the DLL on your machine (see references section). (you can also use the DLL that I have compiled on my machine -windows 2000-). Once you have the DLL, register it on your machine, either using "regsvr32 dllpath\dllname.dll" or use Component Services/MTS (for more information).

    Copy Source:

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Database Code Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Best Practices: The Integrated Project and Portfolio Management Platform.

    Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan.
    FREE! Go There Now!


    NEW! Application Development Tools for the Mainframe Developer

    You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! Download the free Web Application Security eKit

    Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications.
    FREE! Go There Now!


    NEW! Hacking 101

    Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z

    IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects.
    FREE! Go There Now!


    NEW! Improve your build process with IBM Rational Build Forge, Part 2: Automate builds for a real-world Tomcat project

    Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available.
    FREE! Go There Now!


    NEW! Info 2.0: Harnessing the power of Web 2.0 and Enterprise Mashups

    Listen to this webcast to get an overview of Info 2.0 and a technical demo of how to quickly build an enterprise mashup. IBM's Info 2.0 technology leverages emerging Web 2.0 technologies such as mashups, feeds, AJAX, and JSON in order to simplify assembly of information using feeds and services. Come learn about the technical elements of Info 2.0 including the Feed Generation framework, Mashup Engine, and mashup assembly components. Learn how to pull information from databases, departmental information, and the Web to create mashups critical to your company’s success. We will also discuss best practices to help you get started.
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! Webcast: Striking the right balance between manual and automated testing

    Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable.
    FREE! Go There Now!


    Refresh! IBM Rational Systems Development Solution eKit

    With IBM Rational Systems Development Solution, you can deliver products faster with higher quality. Within this kit, Read the “Model Driven Systems Development” white paper to see how to improve product quality and communication. Then check out the rest of the e-Kit to learn more about important topics that can affect the success of any software project through customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems. From start to finish, at every stage in your projects, Rational Systems Development Solution can help your company reach its full potential.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    DATABASE CODE ARTICLES

    - Deployment of the MobiLink Synchronization M...
    - MobiLink Synchronization Wizard in SQL Anywh...
    - Finding Matching Records in Data Access Pages
    - Using the AccessDataSource Control in VS 2005
    - A Closer Look at ADO.NET: The Command Object
    - A Closer Look at ADO.NET: The Connection Obj...
    - Using ADO to Communicate with the Database, ...
    - Code Snippets: Counting Records
    - Constraints In Microsoft SQL Server 2000
    - Multilingual entries into a DB and to be dis...
    - Getting A List of Tables From SQL Server
    - SQL Server Database Creator - .NET Version
    - ADO Recordset Paging
    - Two combos, one textbox example
    - Discussion & Listserv Module by Mike Eck...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek