added gpr speed tracking
This commit is contained in:
@@ -43,6 +43,8 @@ struct SweepTraceBlock {
|
||||
struct RawSweepCollection {
|
||||
std::uint64_t collection_id = 0;
|
||||
std::uint64_t monotonic_ns = 0;
|
||||
std::uint64_t capture_start_ns = 0;
|
||||
std::uint64_t capture_end_ns = 0;
|
||||
std::vector<SweepTraceBlock> traces{};
|
||||
};
|
||||
|
||||
|
||||
@@ -89,6 +89,10 @@ class BinaryReader {
|
||||
return offset_ == bytes_.size();
|
||||
}
|
||||
|
||||
[[nodiscard]] auto remaining_bytes() const -> std::size_t {
|
||||
return bytes_.size() - offset_;
|
||||
}
|
||||
|
||||
private:
|
||||
void ensure_available(std::size_t size) const {
|
||||
if (offset_ + size > bytes_.size()) {
|
||||
@@ -163,6 +167,9 @@ void write_trace_collection(BinaryWriter& writer, std::uint32_t magic, const Raw
|
||||
for (const auto& trace : collection.traces) {
|
||||
write_trace_block(writer, trace);
|
||||
}
|
||||
|
||||
writer.write(collection.capture_start_ns);
|
||||
writer.write(collection.capture_end_ns);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto read_trace_collection(BinaryReader& reader, std::uint32_t expected_magic) -> RawSweepCollection {
|
||||
@@ -181,6 +188,16 @@ void write_trace_collection(BinaryWriter& writer, std::uint32_t magic, const Raw
|
||||
collection.traces.push_back(read_trace_block(reader));
|
||||
}
|
||||
|
||||
if (reader.remaining_bytes() == 0U) {
|
||||
return collection;
|
||||
}
|
||||
if (reader.remaining_bytes() != (sizeof(std::uint64_t) * 2U)) {
|
||||
throw std::runtime_error("Unexpected trailing bytes in trace collection");
|
||||
}
|
||||
|
||||
collection.capture_start_ns = reader.read<std::uint64_t>();
|
||||
collection.capture_end_ns = reader.read<std::uint64_t>();
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user