Initial commit
This commit is contained in:
commit
3d53d40cd9
15 files changed
+1066
No files matched your search
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace rockstream {
|
||||
using Nanoseconds = std::int64_t;
|
||||
Nanoseconds monotonic_ns();
|
||||
|
||||
struct FrameTiming {
|
||||
std::uint64_t id = 0;
|
||||
Nanoseconds scheduled = 0;
|
||||
Nanoseconds submit = 0;
|
||||
Nanoseconds accepted = 0;
|
||||
Nanoseconds first = 0;
|
||||
Nanoseconds final = 0;
|
||||
Nanoseconds reclaimed = 0;
|
||||
std::size_t bytes = 0;
|
||||
std::size_t packets = 0;
|
||||
int intra = -1; // -1 when the SDK did not provide an indicator.
|
||||
};
|
||||
|
||||
// Frame identity is carried in MPP PTS; completion and reclamation are independent.
|
||||
class LatencyLog {
|
||||
public:
|
||||
explicit LatencyLog(std::size_t capacity);
|
||||
void submitted(std::uint64_t id, Nanoseconds scheduled, Nanoseconds begin, Nanoseconds end);
|
||||
void packet(std::uint64_t id, Nanoseconds observed, std::size_t bytes, bool eoi, int intra);
|
||||
void reclaimed(std::uint64_t id, Nanoseconds observed);
|
||||
[[nodiscard]] bool complete(std::uint64_t id) const;
|
||||
[[nodiscard]] const FrameTiming& at(std::uint64_t id) const;
|
||||
[[nodiscard]] std::span<const FrameTiming> frames() const { return frames_; }
|
||||
private:
|
||||
FrameTiming& checked(std::uint64_t id);
|
||||
std::vector<FrameTiming> frames_;
|
||||
};
|
||||
|
||||
// Nearest-rank percentile; sorts its own copy and rejects empty/invalid inputs.
|
||||
double percentile(std::vector<double> values, double percent);
|
||||
void print_latency_report(std::ostream& out, const LatencyLog& log, std::uint32_t warmup);
|
||||
void write_latency_csv(std::ostream& out, const LatencyLog& log, std::uint32_t warmup);
|
||||
} // namespace rockstream
|
||||
Reference in new issue
Block a user