Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.0 - Русский

Change language to:
English - Français - 日本語 - Português -

Please note that the recommended version of Scilab is 2024.1.0. This page might be outdated.
See the recommended documentation of this function

Справка Scilab >> Time and Date > sleep


suspend all code executions (console, scripts, callbacks,..)


sleep(seconds, "s")


duration of the sleep, in milliseconds (decimal number)
duration of the sleep, in seconds (decimal number)


sleep stops Scilab processing any instruction for a specified number of miliseconds or seconds:

input and output in console are suspended.
The CTRL-C interruption is caught but performed only at the end of the sleep.
Scripts and functions:
When sleep(..) is called inside a script or a function, Scilab waits for the given duration before processing the next instruction. CTRL-C in the console is caught but performed only at the end of the sleep.
.. are actions triggered by interactions with menus and with uicontrol interactive graphical components. During the sleep(..), these interactions are caught, and related instructions are buffered. Buffered actions are all performed after sleep()'s end.
Graphics interactions:
sleep(..) does not prevent interacting with graphics, providing that the interaction mode has been turned on before entering the sleep. Then, moving curves, editing graphics labels, etc is still possible during Scilab's sleep. The wake-up does not reset these actions.

Time resolution:
  • Windows systems: 0.5 ms
  • Linux systems: 1 µs
Time resolution is not.. time accuracy: The actual suspension time may be longer than the specified one, due to other processes run in the system, or due to the time spent to process the call.


// Simple examples
tic; sleep(4350); toc
tic; sleep(4.35, "s"); toc

// Testing the sleep's accuracy:
results = [];
disp("Please wait... sleep()s and wake-up are performed...")
for i = -1:4
    dt = 10^i;        // specified duration [ms]
    dta = toc()*1000; // actual duration [ms]
    results = [results ; dt dta ];

// Test of the CTRL-C interruption:
disp("Press CTRL + C keys now: the 15 s sleep is going on")

// Test of interactions with menus:
// [If you are a MacOS user, select the menu "Edit=> Clear figure" instead]
mprintf("During this 30s sleep, click on the figure\n  then on its menu ""Edit => Figure properties""")
// The graphical editor will be actually called only at wake-up
sleep(30, "s")

See also

  • pause — режим паузы, вызов клавиатуры
  • halt — stop execution


  • The fractional part of milliseconds is now accepted and processed (replace xpause(microseconds)).
  • Syntax sleep(seconds, "s") added.
Report an issue
<< realtimeinit Time and Date tic >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 14 15:13:26 CET 2017