Performance Measurement

Chapter 11 - Performance
byJohn Kauffman, Fabio Claudio Ferracchiatiet al.?
Wrox Press ?2002

Before we can start testing, we need a means of extracting useful information from those tests. For our first experiments that measure data access performance, we'll adopt a straightforward technique that uses a simple plan. We'll:

  • Determine the current time (DateTime.Now)

  • Run the data access task to be examined

  • Determine the current time again, and subtract the start time from the end time

Subtracting one DateTime object from another results in a TimeSpan object. This exposes a TotalMilliseconds() method that returns the number of milliseconds in the time span. (Even in this era of GHz CPUs, milliseconds are a precise enough measure of performance.) The code we'll be using to test performance will therefore look something like this:

    Dim startTime As DateTime    Dim howLong As TimeSpan    Dim result As String    startTime = DateTime.Now    ' Perform database task to monitor here    howLong = DateTime.Now.Subtract(startTime)    result = String.Format("{0} ms", howLong.TotalMilliseconds) 

Note 

ASP.NET's Trace.Write() method is one way to display the result string (the result variable) so generated. The perk of using Trace.Write() is that its functionality can be turned on and off by using the web.config file in combination with the Trace attribute of the @Page directive:

 <% @Page Trace="true" %> 

The results of performance tests like these - especially in one-off trials - should not be viewed as gospel. To determine the results in this chapter, each test was run several times in order to reduce the chances of an external process interfering with performance. The numbers should be compared relative to one another, and certainly do not reflect every environment; the machine used to generate the performance numbers for this chapter was a 1.2GHz PIII with 1GB of RAM.



Beginning ASP. NET 2.0 and Databases
Beginning ASP.NET 2.0 and Databases (Wrox Beginning Guides)
ISBN: 0471781347
EAN: 2147483647
Year: 2004
Pages: 263

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net