JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
GpuTimer.hpp
Go to the documentation of this file.
1// Copyright 2026 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include <chrono>
8#include <memory>
9#include <optional>
10
11namespace jngl {
12
28class GpuTimer {
29public:
30 GpuTimer();
31 ~GpuTimer();
32 GpuTimer(const GpuTimer&) = delete;
33 GpuTimer& operator=(const GpuTimer&) = delete;
34 GpuTimer(GpuTimer&&) noexcept;
35 GpuTimer& operator=(GpuTimer&&) noexcept;
36
38 static bool isSupported();
39
42 void start();
43
45 void stop();
46
50
51private:
52 struct Impl;
54};
55
56} // namespace jngl
Measures how long the GPU takes for what's drawn between start() and stop(), e.g.
Definition GpuTimer.hpp:28
void start()
Starts measuring what's drawn from now on.
void stop()
Stops measuring, for poll() to return how long the GPU took once that's known.
std::optional< std::chrono::nanoseconds > poll()
The oldest measurement that has come in since the last call, in the order of stop(),...
static bool isSupported()
Whether the GPU's time can be measured here.
JNGL's main namespace.