Skip to content

Microseconds

Narta Xaymar Dirks edited this page Nov 25, 2026 · 9 revisions

Microseconds BlitzLLVM

Microseconds:UInt64

Returns: A number of microseconds that keeps growing while the program runs, as a UInt64. It does not wrap around like MilliSecs does. It counts from the start of the program, so use the difference between two calls to measure time.

Description

BlitzLLVM This command does not exist in the original Blitz products. BlitzLLVM adds it.

Like MilliSecs, but counts microseconds (millionths of a second) and returns a UInt64, because the count needs far more than 32 bits. This is a BlitzLLVM extension: the originals only have MilliSecs.

  • Keep the result in a variable declared with :UInt64 (for example start:UInt64 = Microseconds()). A variable with no type or with % is an Int, which keeps only the lowest 32 bits and may come out negative; # is a Float, which rounds.

  • Str and Print write all digits, and an expression with a UInt64 and an Int is calculated as a UInt64, so Microseconds() - start is the elapsed time. Comparisons are unsigned, and Int() and Float() convert the value (the Int loses the upper bits).

  • The count starts at 0 when the program starts and only goes forward. It does not follow the system time, so setting the clock (or a change of summer time) while the program runs does not change it. MilliSecs uses the same clock, but counts from the start of the system. Only differences between two calls are meant for measuring.

  • A 32-bit Int would overflow after 35 minutes, and a Float (24 bits of precision) stops counting single microseconds after 16 seconds. See Types everywhere for the other new types.

  • To time a whole program, a frame loop or parts of a frame, and to read the timers of the runtime, see Profiling your own code.

Differences

  • The value is a UInt64, which no original command returns. Assign it to a variable declared with :UInt64 to keep all of its digits, as an Int or a Float only holds part of them.

Examples

start:UInt64 = Microseconds()
Delay 50
Print Microseconds() - start >= 45000
1

Related Commands

Delay BlitzBasic, FreeTimer BlitzBasic, MilliSecs BlitzBasic, WaitTimer BlitzBasic

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally