diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-05 12:00:03 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-05 12:00:03 +0100 |
commit | 0a0c197ed487c343675b62dff8456932c8d5ff7f (patch) | |
tree | 7908290e1ce99dcba10e61e7be5cd047c3a6d3a5 | |
parent | 3b2e51b8f290c9c8511a43a29c80844866a22845 (diff) | |
download | sink-0a0c197ed487c343675b62dff8456932c8d5ff7f.tar.gz sink-0a0c197ed487c343675b62dff8456932c8d5ff7f.zip |
Dump some process stats on exit in the synchronizer.
-rw-r--r-- | synchronizer/main.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index 8e99d54..3f79207 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp | |||
@@ -158,6 +158,58 @@ void qtMessageHandler(QtMsgType type, const QMessageLogContext &context, const Q | |||
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | QString read(const QString &filename) | ||
162 | { | ||
163 | QFile file{filename}; | ||
164 | file.open(QIODevice::ReadOnly); | ||
165 | return file.readAll(); | ||
166 | } | ||
167 | |||
168 | void printStats() | ||
169 | { | ||
170 | |||
171 | #if defined(Q_OS_LINUX) | ||
172 | /* | ||
173 | * See 'man proc' for details | ||
174 | */ | ||
175 | { | ||
176 | auto statm = read("/proc/self/statm").split(' '); | ||
177 | SinkLog() << "Program size:" << statm.value(0).toInt() << "pages"; | ||
178 | SinkLog() << "RSS:"<< statm.value(1).toInt() << "pages"; | ||
179 | SinkLog() << "Resident Shared:" << statm.value(2).toInt() << "pages"; | ||
180 | SinkLog() << "Text (code):" << statm.value(3).toInt() << "pages"; | ||
181 | SinkLog() << "Data (data + stack):" << statm.value(5).toInt() << "pages"; | ||
182 | } | ||
183 | |||
184 | { | ||
185 | auto stat = read("/proc/self/stat").split(' '); | ||
186 | SinkLog() << "Minor page faults: " << stat.value(10).toInt(); | ||
187 | SinkLog() << "Children minor page faults: " << stat.value(11).toInt(); | ||
188 | SinkLog() << "Major page faults: " << stat.value(12).toInt(); | ||
189 | SinkLog() << "Children major page faults: " << stat.value(13).toInt(); | ||
190 | } | ||
191 | |||
192 | //Dump the complete memory map for the process | ||
193 | // std::cout << "smaps: " << read("/proc/self/smaps").toStdString(); | ||
194 | //Dump all sorts of stats for the process | ||
195 | // std::cout << read("/proc/self/status").toStdString(); | ||
196 | |||
197 | { | ||
198 | auto io = read("/proc/self/io").split('\n'); | ||
199 | QHash<QString, QString> hash; | ||
200 | for (const auto &s : io) { | ||
201 | const auto parts = s.split(": "); | ||
202 | hash.insert(parts.value(0), parts.value(1)); | ||
203 | } | ||
204 | SinkLog() << "Read syscalls: " << hash.value("syscr").toInt(); | ||
205 | SinkLog() << "Write syscalls: " << hash.value("syscw").toInt(); | ||
206 | SinkLog() << "Read from disk: " << hash.value("read_bytes").toInt() / 1024 << "kb"; | ||
207 | SinkLog() << "Written to disk: " << hash.value("write_bytes").toInt() / 1024 << "kb"; | ||
208 | SinkLog() << "Cancelled write bytes: " << hash.value("cancelled_write_bytes").toInt(); | ||
209 | } | ||
210 | |||
211 | #endif | ||
212 | } | ||
161 | 213 | ||
162 | int main(int argc, char *argv[]) | 214 | int main(int argc, char *argv[]) |
163 | { | 215 | { |
@@ -223,5 +275,6 @@ int main(int argc, char *argv[]) | |||
223 | 275 | ||
224 | auto ret = app.exec(); | 276 | auto ret = app.exec(); |
225 | SinkLog() << "Exiting: " << instanceIdentifier; | 277 | SinkLog() << "Exiting: " << instanceIdentifier; |
278 | printStats(); | ||
226 | return ret; | 279 | return ret; |
227 | } | 280 | } |