blob: a600a31093335f5e98c39354e4655b1f5c7042fd [file] [log] [blame]
/*
*
* Copyright (c) 2017 Nest Labs, Inc.
* All rights reserved.
*
* This document is the property of Nest. It is considered
* confidential and proprietary information.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Nest.
*
*/
#ifndef CRASH_REPORTER_RUNTIME_LOGGER_H
#define CRASH_REPORTER_RUNTIME_LOGGER_H
#include <chrono>
// Logs the time it took to execute a particular scope
class RuntimeLogger {
public:
RuntimeLogger(const std::string &name)
: name_(name),
start_(std::chrono::steady_clock::now())
{}
~RuntimeLogger()
{
auto duration = std::chrono::steady_clock::now() - start_;
LOG(INFO) << "RuntimeLogger: " << name_ << " took " <<
std::chrono::duration<double>(duration).count() << "s";
}
private:
std::string name_;
std::chrono::steady_clock::time_point start_;
};
#endif