Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function
sets the time unit
sets the initial datetime and starts the chronometer, or waits until a given datetime
realtimeinit(time_unit) realtime(t0) realtime(t)
positive decimal number: time unit duration, in seconds.
decimal number: initial datetime, in
time_unit. This meaning holds when
realtime(…)is called for the first time after the last
realtimeinit(…). This first call sets the datetime origin and restarts the real timer.
decimal number: datetime up to which Scilab must wait before performing the next instruction, expressed in time unit.
sleep(d) waits for a given fixed duration,
realtime(t) will wait the required (unknown) time to reach the
realtimeinit(time_unit) defines the time unit in which the
t specified by
realtime is expressed.
realtimeinit(time_unit), the first call to
realtime(t0) sets the current datetime to
without any wait. Each new call to
realtime(t) then waits till
t is reached. If
t is already passed,
no wait is added.
In the following example, in a loop, a job takes an arbitrary time, from 0 to 1.50 s. This is simulated with a sleep() of random duration. Although this period is not regular, realtime() is used to compensate and print something every 2.00 seconds:
Sleep for Wake-up at Wait until date 0.28 s 0.57 s 2.08 s 0.03 s 2.11 s 4.08 s 1.27 s 5.34 s 6.08 s 0.11 s 6.19 s 8.08 s 1.28 s 9.36 s 10.08 s 0.02 s 10.10 s 12.08 s 0.28 s 12.36 s 14.08 s 0.74 s 14.82 s 16.08 s 1.12 s 17.20 s 18.08 s 1.41 s 19.49 s 20.08 s
|Report an issue|
|<< now||Temps - calendrier date horloge||sleep >>|