TOC PREV NEXT INDEX

Put your logo here!


29 The HLA Timer Module (timer.hhf)


The HLA Timer module provides a set of routines that let you time events with millisecond precision. The Timer module is actually a class with the following definition:


 
timer:  class
 

 
            var
 
                Accumulated:    qword;
 

 
                DateStarted:    date.daterec;
 
                TimeStarted:    time.timerec;
 
                msStarted:      uns32;
 

 
                DateStopped:    date.daterec;
 
                TimeStopped:    time.timerec;
 
                msStopped:      uns32;
 

 
                Running:    boolean;
 
                Valid:      boolean;
 

 
            procedure create;   external;
 

 
            method start;       external;
 
            method restart;     external;
 
            method stop; @returns( "edx:eax" );  external;
 
            method checkPoint; @returns( "edx:eax" ); external;
 

 
        endclass;
 

 

Don't forget that the timer class, like all class objects, will modify the values of the ESI and EDI registers whenever you call a class procedure or method. So don't expect values in ESI or EDI to be preserved across the calls in this module.

timer.Accumulated
 

This field contains the computed time in milliseconds. This field is only valid if the timer.Valid field contains true. If timer.Running contains true, then the timer is still running and the timer.Accumulated field contains the number of milliseconds at the last timer.checkPoint or timer.restart operation.

timer.DateStarted
 
timer.TimeStarted
 
timer.msStarted
 
timer.DateStopped
 
timer.TimeStopped
 
timer.msStopped
 

These are internal variables to the class. You should not modify their values nor should you read their values and use them for anything.

timer.Running
 

This boolean variable indicates that the timer object is currently timing some event. You may read this variable but you should not modify its value.

timer.create;
 

This is the constructor for the class. If you call it via "someObjectName.create();" then this static class procedure will initialize the fields of the specified object. If you call it via "timer.create();" then timer.create will dynamically allocate storage for a timer object and initialize that storage. This call will return a pointer to the new object in the ESI register.

timer.start;
 

This method will initialize the timer so it can begin timing some sequence. Note that this call will set the timer.Running field to true and the timer.Valid field to false.

timer.stop;
 

This method will stop the timer accumulation and returns the accumulated time in EDX:EAX (e.g., the time since the last timer.start call). This call sets timer.Valid to true and timer.Running to false.

timer.checkPoint;
 

This computes the current time in timer.Accumulated without stopping the timer. That is, timer.Valid will be set to true and timer.Running will remain true.

timer.restart;
 

This method restarts the timer after you've stopped the timing via timer.stop. Note that the result accumulated will be the sum of the previous accumulation plus the new time.



TOC PREV NEXT INDEX