Qu

elapsed

Builtin index · REPL & diagnostics

result = elapsed(t)

Input: t · Output: result

What it is

Takes one argument, t (a timer object).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = elapsed(t)
t numbernot documented yet
result number
Returns a number: elapsed seconds so far. A pure read — never stops or resets the timer, callable regardless of running state.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

timer.start()               # same as tic()

heavy_computation()
mid = timer.elapsed()       # peek — does NOT reset, callable again

more_work()
total = timer.stop()        # same as toc() — also a non-resetting read

from repl-diagnostics

timer.start()
acc = 0
for k = 0 to 100000
    acc += k
end for
e = timer.elapsed()
print("elapsed >= 0: {e >= 0}")
s = timer.stop()
print("stop returns: {s}")
print("done, acc = {acc}")
output
elapsed >= 0: true
stop returns: 0.001746
done, acc = 5000050000

from tour

How it works

elapsed(t) — real elapsed seconds so far. A pure read: never stops or resets the timer, callable anytime regardless of running state.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.