Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
host_frame_timing.hpp
Go to the documentation of this file.
1// host_frame_timing.hpp — bounded per-frame timing a window host keeps so a
2// finite run can report how its frames and its GPU bring-up performed.
3//
4// Main-thread only: a host records from the frame it dispatches and reads back
5// from the same thread (the headless screenshot capture runs inside that
6// frame's idle pump). Nothing here allocates after the first reserve.
7#pragma once
8
9#include <chrono>
10#include <cstddef>
11#include <vector>
12
13namespace pulp::view {
14
15using HostClock = std::chrono::steady_clock;
16
18inline double host_elapsed_ms(HostClock::time_point since) noexcept {
19 return std::chrono::duration<double, std::milli>(HostClock::now() - since).count();
20}
21
26 public:
27 static constexpr std::size_t kMaxSamples = 4096;
28
29 void record(double frame_ms) {
30 if (samples_.size() >= kMaxSamples)
31 return;
32 if (samples_.capacity() == 0)
33 samples_.reserve(256);
34 samples_.push_back(frame_ms);
35 }
36
37 const std::vector<double>& samples() const noexcept { return samples_; }
38
39 private:
40 std::vector<double> samples_;
41};
42
43} // namespace pulp::view
Keeps the first kMaxSamples frame durations.
Definition host_frame_timing.hpp:25
void record(double frame_ms)
Definition host_frame_timing.hpp:29
const std::vector< double > & samples() const noexcept
Definition host_frame_timing.hpp:37
static constexpr std::size_t kMaxSamples
Definition host_frame_timing.hpp:27
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
std::chrono::steady_clock HostClock
Definition host_frame_timing.hpp:15
double host_elapsed_ms(HostClock::time_point since) noexcept
Milliseconds elapsed since since on the monotonic host clock.
Definition host_frame_timing.hpp:18