]> git.sesse.net Git - nageru/blob - basic_stats.h
Support audio-only FFmpeg inputs. Somewhat wonky, though.
[nageru] / basic_stats.h
1 #ifndef _BASIC_STATS_H
2 #define _BASIC_STATS_H
3
4 // Holds some metrics for basic statistics about uptime, memory usage and such.
5
6 #include <stdint.h>
7
8 #include <atomic>
9 #include <chrono>
10 #include <memory>
11
12 extern bool uses_mlock;
13
14 class GPUMemoryStats;
15
16 class BasicStats {
17 public:
18         BasicStats(bool verbose, bool use_opengl);
19         void update(int frame_num, int stats_dropped_frames);
20
21 private:
22         std::chrono::steady_clock::time_point start;
23         bool verbose;
24         std::unique_ptr<GPUMemoryStats> gpu_memory_stats;
25
26         // Metrics.
27         std::atomic<int64_t> metric_frames_output_total{0};
28         std::atomic<int64_t> metric_frames_output_dropped{0};
29         std::atomic<double> metric_start_time_seconds{0.0 / 0.0};
30         std::atomic<int64_t> metrics_memory_used_bytes{0};
31         std::atomic<double> metrics_memory_locked_limit_bytes{0.0 / 0.0};
32 };
33
34 // Holds some metrics for GPU memory usage. Currently only exposed for NVIDIA cards
35 // (no-op on all other platforms).
36
37 class GPUMemoryStats {
38 public:
39         GPUMemoryStats(bool verbose);
40         void update();
41
42 private:
43         bool verbose, supported;
44
45         // Metrics.
46         std::atomic<int64_t> metric_memory_gpu_total_bytes{0};
47         std::atomic<int64_t> metric_memory_gpu_dedicated_bytes{0};
48         std::atomic<int64_t> metric_memory_gpu_used_bytes{0};
49         std::atomic<int64_t> metric_memory_gpu_evicted_bytes{0};
50         std::atomic<int64_t> metric_memory_gpu_evictions{0};
51 };
52
53 #endif  // !defined(_BASIC_STATS_H)