Runtime v2.81 · Updated Sep 30, 2026

Timer

Millisecond stopwatch helper for script timing checks and guarded waits.

Syntax

Timer(auto_start=True)

Constructor parameters

NameDescription
auto_startBoolean
Start counting immediately after creation.
Optional · Positional or named
Default: True

Returns

Timer

Behavior / side effects

Millisecond stopwatch helper for script timing checks and guarded waits.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

timer = Timer(auto_start=False)
timer.start()
while not timer.is_elapsed(2000):
    wait(50)
timer.stop()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

None

Fields

NameDescription
auto_startBoolean
Whether the timer starts immediately after creation. Assign True to start; assign False to pause.
Default: True
Constructor example
timer = Timer()
if timer.is_elapsed(500):
    text("half-second passed")

Methods

10 methods

Timer.start

Start counting if the timer is currently stopped.

Syntax

timer.start()

Parameters

None

Returns

Timer — Returns the same timer for chaining.

Behavior / side effects

Start counting if the timer is currently stopped.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer(auto_start=False)
timer.start()
wait(100)
print(timer.elapsed_ms())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.pause

Pause counting while preserving elapsed milliseconds.

Syntax

timer.pause()

Parameters

None

Returns

Timer — Returns the same timer for chaining.

Behavior / side effects

Pause counting while preserving elapsed milliseconds.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
wait(100)
timer.pause()
print(timer.elapsed_ms())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.resume

Resume counting from paused state.

Syntax

timer.resume()

Parameters

None

Returns

Timer — Returns the same timer for chaining.

Behavior / side effects

Resume counting from paused state.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
timer.pause()
timer.resume()
wait(100)
print(timer.elapsed_ms())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.stop

Stop counting and keep elapsed milliseconds frozen.

Syntax

timer.stop()

Parameters

None

Returns

Timer — Returns the same timer for chaining.

Behavior / side effects

Stop counting and keep elapsed milliseconds frozen.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
wait(100)
timer.stop()
print(timer.elapsed_ms())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.reset

Reset elapsed time to 0 while keeping the current running state.

Syntax

timer.reset()

Parameters

None

Returns

Timer — Returns the same timer for chaining.

Behavior / side effects

Reset elapsed time to 0 while keeping the current running state.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
wait(100)
timer.reset()
print(timer.elapsed_ms())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.restart

Reset elapsed time to 0 and start counting immediately.

Syntax

timer.restart()

Parameters

None

Returns

Timer — Returns the same timer for chaining.

Behavior / side effects

Reset elapsed time to 0 and start counting immediately.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer(auto_start=False)
timer.restart()
wait(100)
print(timer.elapsed_ms())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.elapsed_ms

Read total elapsed milliseconds.

Syntax

timer.elapsed_ms()

Parameters

None

Returns

Number — Elapsed milliseconds.

Behavior / side effects

Read total elapsed milliseconds.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
wait(100)
print(timer.elapsed_ms())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.is_elapsed

Check whether elapsed time is greater than or equal to the provided milliseconds.

Syntax

timer.is_elapsed(time)

Parameters

NameDescription
timeNumber
Target milliseconds threshold.
Required · Positional or named
No default

Returns

Boolean — true when elapsed time reached or exceeded the threshold.

Behavior / side effects

Check whether elapsed time is greater than or equal to the provided milliseconds.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
wait(500)
if timer.is_elapsed(500):
    print("Elapsed")

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.is_running

Check whether the timer is currently counting.

Syntax

timer.is_running()

Parameters

None

Returns

Boolean — true when timer is counting.

Behavior / side effects

Check whether the timer is currently counting.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
print(timer.is_running())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Timer.is_paused

Check whether the timer is paused after being started.

Syntax

timer.is_paused()

Parameters

None

Returns

Boolean — true when timer is paused.

Behavior / side effects

Check whether the timer is paused after being started.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Measure time in the calling flow
timer = Timer()
timer.pause()
print(timer.is_paused())

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs