display_set_sleep_margin

This function can be used to set the sleep margin value used for the render timing of your game, and requires a millisecond value. The default values are as follows:

PlatformMilliseconds
Windows10
macOS10
Ubuntu10
HTML510
Android4
iOS4
Xbox10
PS410
Nintendo Switch10

Note that even if the timing method is set to use vsync timing, the sleep margin will have some effect over the rendering of the game, and so you should take care when setting this value. For more information on display timing, please see display_set_timing_method().

NOTE In addition to the Sleep Margin, you can further control your performance and power consumption on Windows by adjusting the thread scheduler's resolution at runtime.

 

Syntax:

display_set_sleep_margin(milliseconds);

ArgumentTypeDescription
millisecondsRealThe number of milliseconds for the sleep margin

 

Returns:

N/A

 

Example:

if (display_get_timing_method() != tm_sleep)
{
    display_set_timing_method(tm_sleep);
    if (display_get_sleep_margin() != 20)
    {
        display_set_sleep_margin(20);
    }
}

The above code will check the timing method and then if it's not set to tm_sleep it will be set to that and the sleep margin set to 20.