Dead simple Clarion Stopwatch Class

Something I needed today but didn’t have.

Based on the .NET Stopwatch Class but only using the precision of Clarion Clock() and Today()


  • Start
  • StartNew
  • Stop
  • Reset
  • Restart
  • Elapsed
  • ToString

SW Stopwatch


    ! Do some things that take time...
    ! Perhaps Thread.Sleep(10000)


    Message('Elapsed Ticks: ' & SW.Elapsed())
    Message('Time Elapsed: ' & SW.ToString())  ! e.g. 2 days, 00:12:54


I was thinking about this just recently and procrastinating on creating it myself. Thanks! This will save me a bunch of time.

1 Like

Note: If you’re less squeamish about using includes, and composing classes from other classes

You might want to take a peek at my ctTimedResultsClass

It uses ctDateTimeLong which can be found in this folder:

1 Like


But yes, do check out the work from Mark! In this case I just wanted something very self contained.
The IFDEF technique around the EQUATES would be a good safeguard which I failed to include in my original above.

   OMIT('*** IFDEF ***', TIME:Second)
TIME:Tick   EQUATE(  1)
TIME:Second EQUATE(100 * TIME:Tick)
TIME:Minute EQUATE( 60 * TIME:Second)
TIME:Hour   EQUATE( 60 * TIME:Minute)
TIME:Day    EQUATE( 24 * TIME:Hour  )
 !END-OMIT('*** IFDEF ***', TIME:Second)

I was just reading a blog over at hanselman land, Proper benchmarking to diagnose and solve a .NET serialization bottleneck, where he mentions the .NET Stopwatch class and linked to the source code.