The System class provides basic system functionality, such as the sleep() function for waiting, or the clock() function for timing functionality.
// sleep (pause) for two and a half seconds
System.sleep(2500);
// now measure the time it takes for the user to press ok
const clock1 = System.clock();
alert("Press Ok.");
const clock2 = System.clock();
const seconds = (clock2 - clock1) / System.getClocksPerSecond();
alert(`It took ${seconds} seconds to click Ok.`);
// now launch notepad
System.execute("notepad"); Creates a system beep. If no parameters are specified, the function creates a default system beep. If parameters are specified, the function creates a beep having the given frequency and duration.
The value of CPU clock.
Returns the CPU clock value. This is useful for measuring how long a piece of code takes to run. It is a basic tool for performance testing. By calling the getClocksPerSecond() function, the user can determine how many seconds have elapsed, to a high degree of accuracy.
The process id of the new process, or zero if the operation failed.
Calling execute runs another program. The program is launched asynchronously, meaning that execution in the calling scope is not blocked, and the program will be run in the background. The command parameter represents the entire command line, including program path and command line parameters.
The number of clock ticks per second.
Returns number of CPU clock ticks per second. This is useful in conjunction with the clock() method.
Pauses execution in a thread-friendly manner for the specified number of milliseconds.
The number of seconds elapsed since January 1, 1970 UTC.
Returns the number of seconds elapsed since 00:00 hours, January 1, 1970 UTC.