Chia-hung Duan 4dc3bcf012 Reland "[scudo] Add a Timer class to assist performance measurement"
This reverts commit 2e9bcadb7c8acaa8f6ec7d807e5666246923e468.

Differential Revision: https://reviews.llvm.org/D146772
2023-04-03 22:47:59 +00:00

30 lines
787 B
C++

//===-- timing.cpp ----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "timing.h"
namespace scudo {
Timer::~Timer() {
if (Manager)
Manager->report(*this);
}
ScopedTimer::ScopedTimer(TimingManager &Manager, const char *Name)
: Timer(Manager.getOrCreateTimer(Name)) {
start();
}
ScopedTimer::ScopedTimer(TimingManager &Manager, const Timer &Nest,
const char *Name)
: Timer(Manager.nest(Nest, Name)) {
start();
}
} // namespace scudo