Files
fireusage/usage.h

32 lines
604 B
C
Raw Permalink Normal View History

2019-05-10 20:59:58 -07:00
#pragma once
2019-05-18 12:16:19 -07:00
#include <sys/resource.h>
#include <chrono>
2019-05-10 20:59:58 -07:00
#include <string>
namespace fireusage {
class UsageTracker {
2019-05-18 12:16:19 -07:00
public:
void AddEvents(uint64_t num);
void AddEvent();
2019-05-18 12:16:19 -07:00
void Start();
void Stop();
void Log(const std::string_view& title = "");
2019-05-10 20:59:58 -07:00
2019-05-18 12:16:19 -07:00
private:
bool running_ = false;
uint64_t events_ = 0;
std::chrono::nanoseconds wall_time_;
std::chrono::nanoseconds user_time_;
std::chrono::nanoseconds sys_time_;
uint64_t vol_ctxt_sw_ = 0;
uint64_t invol_ctxt_sw_ = 0;
2019-05-18 12:16:19 -07:00
std::chrono::steady_clock::time_point start_time_;
rusage start_usage_;
2019-05-10 20:59:58 -07:00
};
2019-05-18 12:16:19 -07:00
} // namespace fireusage