blob: b74b5892ea01cab8c209d48b4fdd629d0201e37a [file] [log] [blame]
Sui Chen03eba282021-02-11 11:35:56 -08001#ifndef _UTIL_HPP_
2#define _UTIL_HPP_
3
4#include <string>
5#include <string_view>
6
7namespace metric_blob
8{
9
10struct TcommUtimeStime
11{
12 std::string tcomm;
13 float utime;
14 float stime;
15};
16
17TcommUtimeStime parseTcommUtimeStimeString(std::string_view content,
18 long ticksPerSec);
19std::string readFileIntoString(std::string_view fileName);
20bool isNumericPath(std::string_view path, int& value);
21TcommUtimeStime getTcommUtimeStime(int pid, long ticksPerSec);
22std::string getCmdLine(int pid);
23bool parseMeminfoValue(std::string_view content, std::string_view keyword,
24 int& value);
25bool parseProcUptime(const std::string_view content, double& uptime,
26 double& idleProcessTime);
27long getTicksPerSec();
28char controlCharsToSpace(char c);
29std::string trimStringRight(std::string_view s);
30
31} // namespace metric_blob
32
33#endif