ScriptForge.Timer service

The Timer service measures the amount of time it takes to run user scripts.

A Timer measures durations. It can be:

Tip Icon

Durations are expressed in seconds with a precision of 3 decimal digits (milliseconds). A duration value of 12.345 means 12 seconds and 345 milliseconds


Service invocation

Before using the Timer service the ScriptForge library needs to be loaded or imported:

note

• Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
from scriptforge import CreateScriptService


In Basic

The example below creates a Timer object named myTimer and starts it immediately.


    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
    Dim myTimer As Variant
    myTimer = CreateScriptService("Timer", True)
    'The timer starts immediately when the second argument = True, default = False
  

It is recommended to free resources after use:


    Set myTimer = myTimer.Dispose()
  
In Python

    from scriptforge import CreateScriptService
    myTimer = CreateScriptService("Timer", start = True)
    # ...
    myTimer = myTimer.Dispose()
  

Properties

Name

Readonly

Type

Description

Duration

Yes

Double

The actual running time elapsed since start or between start and stop (does not consider suspended time)

IsStarted

Yes

Boolean

True when timer is started or suspended

IsSuspended

Yes

Boolean

True when timer is started and suspended

SuspendDuration

Yes

Double

The actual time elapsed while suspended since start or between start and stop

TotalDuration

Yes

Double

The actual time elapsed since start or between start and stop (including suspensions and running time)


Tip Icon

Note that the TotalDuration property is equivalent to summing the Duration and SuspendDuration properties.


Methods

All methods do not require arguments and return a Boolean value.

If the returned value is False, then nothing happened.

Name

Description

Returned value