Example program to show memory usage.
More...
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <unistd.h>
#include "JSystem/JShell.hh"
#include "JSystem/JSystemToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
Example program to show memory usage.
- Author
- mdejong
Definition in file JMemoryUsage.cc.
◆ main()
int main |
( |
int | argc, |
|
|
char ** | argv ) |
Definition at line 21 of file JMemoryUsage.cc.
22{
25
26 size_t size_B;
27 unsigned int sleep_us;
28 bool use;
30
31 try {
32
33 JParser<> zap(
"Example program to show memory usage.");
34
39
40 zap(argc, argv);
41 }
42 catch(const exception &error) {
43 FATAL(error.what() << endl);
44 }
45
46 if (sleep_us == 0) {
47 sleep_us = 1;
48 }
49
51
52 const size_t size = size_B /
sizeof(
data_type);
53
54 {
55 cout << endl;
57
59
60 usleep(sleep_us);
61
63
64 if (use) {
65
66 for (size_t i = 0; i != size; ++i) {
67 buffer[i] = i;
68 }
69
70 usleep(sleep_us);
71
73 }
74
75 delete[] buffer;
76
77 usleep(sleep_us);
78
80 }
81 {
82 cout << endl;
84
86
87 buffer.reserve(size);
88
90
91 if (use) {
92
93 for (size_t i = 0; i != size; ++i) {
94 buffer.push_back(i);
95 }
96
97 usleep(sleep_us);
98
100 }
101
102 buffer.clear();
103
104 usleep(sleep_us);
105
107
108 {
110
111 buffer.swap(zbuf);
112 }
113
114 usleep(sleep_us);
115
117 }
118 {
119 cout << endl;
121
122 size_t N = 10;
123
125
126 if (use) {
127
128 for (size_t i = 0; i != N; ++i) {
129 buffer[i].resize(size / N);
130 }
131
132 usleep(sleep_us);
133
135 }
136
137 buffer.clear();
138
139 usleep(sleep_us);
140
142
143 {
145
146 buffer.swap(zbuf);
147 }
148
149 usleep(sleep_us);
150
152 }
153}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
float getMemoryUsage(JShell &shell, const pid_t pid)
Get memory usage in percent of given process identifier.
Auxiliary data structure for floating point format specification.
Data structure for measured coincidence rates of all pairs of PMTs in optical module.