The Database Managers, Inc.

Contact The Database Managers, Inc.

Use an RSS enabled news reader to read these articles.Use an RSS enabled news reader to read these articles.

Timing an Event in DataFlex

by Curtis Krauskopf

"How long did that take?" That's a question I ask myself when I'm doing software engineering. I oftentimes encounter two different algorithms that perform the same task but they do it in significantly different amounts of time.

Size does matter. A process that takes one second to finish on my development database can take an hour on my customer's database because their database is 3600 times bigger than my test database. Sometimes that's acceptable. Most often it's not.

So I need to time how long things take in DataFlex. Over the years, I've developed some useful techniques for measuring how long things take. Some are so accurate that they even detect the amount of time that Windows steals from a process to do its own processing.

Ticking away the moments that make up a dull day.
You fritter and waste the hours in an offhand way.
Kicking around on a piece of ground in your hometown.
Waiting for someone or something to show you the way.

The Dark Side of the Moon: Pink Floyd
Lyrics by Mason, Waters, Wright, Gilmore

DataFlex has three commands that are able to either directly or indirectly time how long an event takes:



SYSDATE and SYSDATE4 both do almost the same thing. They both obtain the current date and time information from the operating system. The only difference between them is that SYSDATE returns a two digit year (03) whereas SYSDATE4 returns a four digit year (2003). Here's an example of how to use SYSDATE4 (using SYSDATE is identical except replace the SYSDATE4 command with SYSDATE):

// A simple demonstration of the sysdate4 command.

date today
integer hour minute second
sysdate4 today hour minute second
showln "Today is " today
showln "The current time is: " hour ":" minute ":" second

showln "Press any key to continue."
string akey 1
inkey akey

This is the output:

Today is 08/25/2003
The current time is: 12:51:25
Press any key to continue.

The date will appear in the default format for your DataFlex installation. This is defined in the DFCONFIG utility. The three available date formats are:


In addition, the separator character (which defaults to '/') can also be defined. Any character can be used. The most common separators I've seen are:


Next: How Long Did that Take?

Jump Directly To...
How Long Did that Take?
Why is this so Inconsistent?

A Better Timer
Using SYSDATE for Microsecond Timing
Measuring the SET_TIMER resolution

Copyright 2003-2010 The Database Managers, Inc.

DataFlex Decompiler
DataFlex: Tips | Freeware | WebApp Server | Books | Links
Services | Programming | Contact Us | Recent Updates

Send feedback to: