25#ifndef __SYSTEM_TOOLS_HPP__
26#define __SYSTEM_TOOLS_HPP__
36 std::ifstream ifs(file_name.c_str());
47 return std::string(
nm);
50inline long get_page_size()
52 return sysconf(_SC_PAGESIZE);
55inline long get_num_pages()
57 return sysconf(_SC_PHYS_PAGES);
60inline long get_total_memory()
62 return get_page_size() * get_num_pages();
65inline auto get_proc_status()
72 std::ifstream ifs(
"/proc/self/status");
77 while (std::getline(ifs, str)) {
78 auto p = str.find(
"VmHWM:");
79 if (p != std::string::npos) {
80 std::stringstream s(str.substr(p + 7));
85 std::printf(
"runtime::get_proc_status(): wrong units");
91 p = str.find(
"VmRSS:");
92 if (p != std::string::npos) {
93 std::stringstream s(str.substr(p + 7));
98 std::printf(
"runtime::get_proc_status(): wrong units");
113inline int get_proc_threads()
117 std::ifstream ifs(
"/proc/self/status");
120 while (std::getline(ifs, str)) {
121 auto p = str.find(
"Threads:");
122 if (p != std::string::npos) {
123 std::stringstream s(str.substr(p + 9));
Namespace of the SIRIUS library.
auto hostname()
Get host name.
bool file_exists(std::string file_name)
Check if file exists.