Working getrusage and wall clock metrics
This commit is contained in:
18
usage.h
18
usage.h
@@ -1,15 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <sys/resource.h>
|
||||
|
||||
namespace fireusage {
|
||||
|
||||
class UsageTracker {
|
||||
public:
|
||||
UsageTracker(const std::string_view& plural_resource_name);
|
||||
void AddEvents(uint64_t num);
|
||||
void AddEvent();
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
void Log();
|
||||
|
||||
private:
|
||||
const std::string plural_resource_name_;
|
||||
bool running_ = false;
|
||||
uint64_t events_ = 0;
|
||||
std::chrono::nanoseconds wall_time_;
|
||||
std::chrono::nanoseconds user_time_;
|
||||
std::chrono::nanoseconds sys_time_;
|
||||
|
||||
std::chrono::steady_clock::time_point start_time_;
|
||||
rusage start_usage_;
|
||||
};
|
||||
|
||||
} // namespace fireusage
|
||||
|
||||
Reference in New Issue
Block a user