Project Theseus
KnowledgeBase

[ EpikTimer ]

| Recent Changes | Find Page | All Pages | Front Page | | | Help |
 


 Epik-Timer

A precision timing component for Lazarus and the Free Pascal Compiler

 About

EpikTimer is a programmer's stopwatch that is capable of measuring very short events with traceably high precision over long periods of time. It's simple to use, consumes virtually no CPU and requires only 25 bytes of ram to implement a timer instance. The component provides a single internal timer... but unlimited numbers can be declared externally and linked to a single EpikTimer component on the form.

The download contains the component, an installation package and a demo application (screenshot) that illustrates the features of the component along with some instrumentation for evaluating the clock sources on a given system.

This component was designed for cross-platform applications and was written specifically for the Lazarus IDE and Free Pascal Compiler. It includes a demo application.

 Author

Tom Lisjac VlxAdmin

 License

LGPL (please contact the author if the LGPL doesn't work with your project licensing)

 Download

The latest stable release can be found on the Lazarus CCR Files page.

 Change Log

Initially written on 24-06-2003 TL
Pre-release 30-06-2003 TL - Needs testing on the BSD's and Win32
Version 0.1 1-7-2003 TL
Version 0.2 3-7-2003 TL

 Getting the latest source from CVS

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/lazarus login
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/lazarus co epiktimer

 Dependencies / System Requirements

Nanosecond resolution is supported on Intel Pentium versions with a Timestamp Counter.
Microsecond system clock is the default timebase.
Status: Beta

Issues: Needs testing... especially on Win32, FreeBSD and older machines that lack TSC hardware.

 Installation

 Usage

Drop the component on a form. The component contains a single timer instance and parameterless calls to start, stop, elapsed and clear will implicitly reference it.

If the timer is named ET:

Procedure InstrumentedCall;
  Begin
    ET.Clear; // optional... timer is cleared at creation
    ET.Start;
    ExecuteFirstTimedSection;
    ET.Stop; // the timer is actually paused and can be restarted later
    TimedSection1:=ET.Elapsed; // store the elapsed in a global
    MakeAnUntimedOverheadCall; // not counted in the timer
    ET.Start; //resume the timer... continue accumulating ticks
    CallTimedSection2;
    TimedSection2:=ET.Elapsed; //timer keeps running... we've just sample it.
    CallTimedSection3;
    CallSomethingElse;
    TimedSection3:=ET.Elapsed; //keep counting... tap the elapsed
    CallTimedSection4;
    TimedSection4:=ET.Elapsed; //keep counting... tap the elapsed
    ET.clear // done... timer is stopped and zeroed
  end;

You can also create any number of timers from a single component on the form by declaring a TimerData record and passing it as a parameter to start, stop, elapsed and clear using the overloaded methods in the component. An example would be:

Function TimedExecution:Extended;
  Var DiskAccessTime:TimerData;
  Begin
    ET.Clear(DiskAccessTimer); // Declared timers *must* be cleared before use. 
    ET.Start(DiskAccessTimer);
    ExecuteTheTimedSection;
    Result:=ET.Elapsed(DiskAccessTimer); // the timer keeps running...
    etc...

See etdemo.pas for additional examples of component usage

 The ETDemo Application

The ETDemo application does not require EpikTimer to be installed in order
to compile and operate. I never liked having to install a palette full of
components only to find out that I didn't like any of them! :)

Installation:
Here's a screenshot of the demo.

User Contributed Notes


None yet


Last modified on November 1, 2003 at 09:17:18-UTC

Powered by EpikWebsite

This Project is generously hosted by SourceForge.net Logo


Page created in 0.028478 seconds