Performance Lab

PerfLab
Class PerformanceLab

java.lang.Object
  |
  +--PerfLab.PerformanceLab

public class PerformanceLab
extends java.lang.Object

Title: Performance Lab

Description: A series of classes to assist with java performace experimentation and learning

Copyright: Copyright (c) Kurt Kirkham

Company: Indianapolis Java User's Group

Version:
1.0

To use this class:

1. Import the package.

import PerfLab.*;

2. Instantiate the class.

protected PerformanceLab m_objStringBuffers = new
PerformanceLab("Test Description");

3. Execute all setup code that you want outside of the test.

4. Get the starting time.

m_objStringBuffers.setStartTime();

5. Execute all code that you want to be timed.

6. Get the ending time.

m_objStringBuffers.setEndTime();

7. Calculate and print the results.

m_objStringBuffers.calculateTimeDifference();

8. After running all tests, compare the results

PerformanceLab.compareTests(m_objStrings,m_objStringBuffers);

Author:
Kurt Kirkham

Field Summary
protected  long m_lEndTime
           
protected  long m_lStartTime
           
protected  long m_lTimeDif
           
protected  java.lang.String m_strTestDesc
           
 
Constructor Summary
PerformanceLab()
          Constructor.
PerformanceLab(java.lang.String p_strTestDesc)
          Constructor passing Test Description.
 
Method Summary
 void calculateTimeDifference()
          Compare two times and print the difference.
static void compareTests(PerformanceLab p_objTest1, PerformanceLab p_objTest2)
          Compare two test results and print the difference.
static long compareTimes(long p_lStartTime, long p_lEndTime)
          Compare two times and print the difference.
static long getCurrentTime()
          Get current time.
 long getEndTime()
          Get End Time.
 long getStartTime()
          Get Start Time.
 java.lang.String getTestDesc()
          Get Test Description.
 long getTimeDifference()
          Get Time Difference.
static void printResults(java.lang.String p_strTestDesc, long p_lStartTime, long p_lEndTime, long p_lTimeDif)
          Print Results.
 void setEndTime()
          Set End Time.
 void setStartTime()
          Set Start Time.
 void setTestDesc(java.lang.String p_strTestDesc)
          Set Test Description.
 void setTimeDifference(long p_lTimeDif)
          Set Time Difference.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_strTestDesc

protected java.lang.String m_strTestDesc

m_lStartTime

protected long m_lStartTime

m_lEndTime

protected long m_lEndTime

m_lTimeDif

protected long m_lTimeDif
Constructor Detail

PerformanceLab

public PerformanceLab()
Constructor.

PerformanceLab

public PerformanceLab(java.lang.String p_strTestDesc)
Constructor passing Test Description.
Parameters:
p_strTestDesc - Test Description
Method Detail

setTestDesc

public void setTestDesc(java.lang.String p_strTestDesc)
Set Test Description.
Parameters:
p_strTestDesc - Test Description

getTestDesc

public java.lang.String getTestDesc()
Get Test Description.
Returns:
Test Description

setStartTime

public void setStartTime()
Set Start Time.

The time is set as the current time.


getStartTime

public long getStartTime()
Get Start Time.

Returns:
Start Time of test.

setEndTime

public void setEndTime()
Set End Time.

The time is set as the current time.


getEndTime

public long getEndTime()
Get End Time.


setTimeDifference

public void setTimeDifference(long p_lTimeDif)
Set Time Difference.

The time difference is set.

Parameters:
p_lTimeDif - Time Difference.

getTimeDifference

public long getTimeDifference()
Get Time Difference.


getCurrentTime

public static long getCurrentTime()
Get current time.
Returns:
Current Time

compareTimes

public static long compareTimes(long p_lStartTime,
                                long p_lEndTime)
Compare two times and print the difference.
Parameters:
p_lStartTime - Starting Time
p_lEndTime - Ending Time
Returns:
Difference between Ending Time and Starting Time

calculateTimeDifference

public void calculateTimeDifference()
Compare two times and print the difference.
Returns:
Difference between Ending Time and Starting Time

compareTests

public static void compareTests(PerformanceLab p_objTest1,
                                PerformanceLab p_objTest2)
Compare two test results and print the difference.
Parameters:
p_objTest1 - Test 1 Performance Lab
p_objTest2 - Test 2 performance Lab

printResults

public static void printResults(java.lang.String p_strTestDesc,
                                long p_lStartTime,
                                long p_lEndTime,
                                long p_lTimeDif)
Print Results.

Performance Lab

Copyright © 2000 IndyJUG.
All Rights Reserved.