Files
test2/source/blender/blenlib/BLI_time.h
Christoph Neuhauser a889aa9e38 WM: Switch to high-resolution timers on Windows for sleeping
This PR introduces a more precise sleep function `BLI_time_sleep_duration`
using high-resolution timers on Windows. By default, Windows only has a
resolution of 15.25ms for the regular `Sleep` function. Using more precise
timers makes sure that Blender can wake from sleep quicker and improves
performance at high frame rates.

High-resolution timers may have better energy efficiency than using
`timeBeginPeriod`/`timeEndPeriod` that change the timer resolution globally
on some versions of Windows.

Pull Request: https://projects.blender.org/blender/blender/pulls/140221
2025-07-15 10:02:09 +02:00

34 lines
955 B
C

/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bli
* \brief Platform independent time functions.
*/
#pragma once
/**
* Return an indication of time, expressed as seconds since some fixed point.
* Successive calls are guaranteed to generate values greater than or equal to the last call.
*/
extern double BLI_time_now_seconds(void);
/** `int` version of #BLI_time_now_seconds. */
extern long int BLI_time_now_seconds_i(void);
/**
* Platform-independent sleep function.
* \param ms: Number of milliseconds to sleep
*/
void BLI_time_sleep_ms(int ms);
/**
* Platform-independent high-resolution sleep function.
* Using this function can have advantages over \see BLI_time_sleep_ms on Windows due to a default
* non-precise sleep resolution of 15.25ms.
* \param us: Number of microseconds to sleep
*/
void BLI_time_sleep_precise_us(int us);