Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f131d8be authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi Committed by Android (Google) Code Review
Browse files

Merge "[aapt2] Change the base timestamp of the traces" into main

parents 1fc9dac6 1e496964
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -44,13 +44,15 @@ struct TracePoint {

std::vector<TracePoint> traces;
bool enabled = true;
constinit std::chrono::steady_clock::time_point startTime = {};

int64_t GetTime() noexcept {
  auto now = std::chrono::steady_clock::now();
  return std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
  if (startTime == decltype(tracebuffer::startTime){}) {
    startTime = now;
  }
  return std::chrono::duration_cast<std::chrono::microseconds>(now - startTime).count();
}

} // namespace anonymous

void AddWithTime(std::string tag, char type, int64_t time) noexcept {
  TracePoint t = {type, getpid(), time, std::move(tag)};
@@ -90,6 +92,8 @@ void Flush(const std::string& basePath) {
  traces.clear();
}

}  // namespace

} // namespace tracebuffer

void BeginTrace(std::string tag) {
@@ -166,7 +170,7 @@ FlushTrace::FlushTrace(std::string_view basepath, std::string_view tag,

FlushTrace::~FlushTrace() {
  if (!tracebuffer::enabled) return;
  tracebuffer::Add(tag_, tracebuffer::kEnd);
  tracebuffer::Add(std::move(tag_), tracebuffer::kEnd);
  tracebuffer::Flush(basepath_);
}