-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics.cpp
More file actions
40 lines (31 loc) · 959 Bytes
/
Copy pathmetrics.cpp
File metadata and controls
40 lines (31 loc) · 959 Bytes
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
35
36
37
38
39
//
// Created by user on 7/1/2022.
//
#include <chrono>
#include <iostream>
#include <fstream>
using namespace std;
using namespace std::chrono;
void calculate_total_time ( std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long,
std::ratio<1, 1000000000>>> start)
{
auto stop = std::chrono::system_clock::now();
using Fpseconds =std::chrono::duration<float, std::chrono::seconds::period>;
std::chrono::duration<double> seconds = stop-start;
cout << "total creation time is "<<seconds.count()<<endl;
cout << "i'm here";
}
void calculate_peak_RAM ()
{
FILE *fp;
unsigned long peaksize = 0;
char buf[1024];
fp = fopen("/proc/self/status", "r");
while (fgets(buf, sizeof(buf)-1, fp) != NULL) {
if (sscanf(buf, "VmPeak:%lu", &peaksize) > 0) {
break;
}
}
fclose(fp);
cout<< "peak ram usage:" <<peaksize/1024 <<endl;
}