-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
34 lines (30 loc) · 1020 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <cctype>
#include <unistd.h>
#include <ios>
#include <fstream>
#include "csp.h"
#include "coloration.h"
#include "arbre_dom.h"
#include "build_in_problems.h"
#include "interface.h"
using namespace std;
void get_ram_usage(long& ram_usage, unsigned long& swap_usage) {
long rss;
unsigned long vsize;
ifstream proc_stat("/proc/self/stat", ios_base::in);
string pid, comm, state, ppid, pgrp, session, tty_nr;
string tpgid, flags, minflt, cminflt, majflt, cmajflt;
string utime, stime, cutime, cstime, priority, nice;
string O, itrealvalue, starttime;
proc_stat >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
>> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
>> utime >> stime >> cutime >> cstime >> priority >> nice
>> O >> itrealvalue >> starttime >> vsize >> rss;
ram_usage = rss * sysconf(_SC_PAGE_SIZE) / 1024;
swap_usage = vsize / 1024.0;
}
int main(){
interface();
return 0;
}