API reference / Input and time
SDL_GetTicksNS
Function, SDL3
Gets the time since SDL started, in nanoseconds. Use two readings to measure a time.
Declaration
#include <SDL3/SDL.h>
Uint64 SDL_GetTicksNS(void);Return value
The number of nanoseconds.
Example
last_ticks = SDL_GetTicksNS();See this code run in Move with time. Download the full program (.zip)
Notes
SDL_NS_PER_SECONDis the number of nanoseconds in one second.
In SDL2
SDL2 has no such function. Use SDL_GetPerformanceCounter with SDL_GetPerformanceFrequency.