|
|
|
@ -1,16 +1,12 @@
|
|
|
|
|
#include "iostats.h"
|
|
|
|
|
#include "string_utils.h"
|
|
|
|
|
#include "timing.hpp"
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
|
|
Clock::time_point lastUpdate = Clock::now(); /* ns */
|
|
|
|
|
|
|
|
|
|
void getIoStats(void *args) {
|
|
|
|
|
iostats *io = reinterpret_cast<iostats *>(args);
|
|
|
|
|
if (io) {
|
|
|
|
|
Clock::time_point now = Clock::now(); /* ns */
|
|
|
|
|
Clock::duration timeDiff = now - lastUpdate;
|
|
|
|
|
float timeDiffSecs = (float)timeDiff.count() / (float)1000000000; // Time diff in seconds
|
|
|
|
|
std::chrono::duration<float> time_diff = now - io->last_update;
|
|
|
|
|
|
|
|
|
|
io->prev.read_bytes = io->curr.read_bytes;
|
|
|
|
|
io->prev.write_bytes = io->curr.write_bytes;
|
|
|
|
@ -26,12 +22,14 @@ void getIoStats(void *args) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
io->diff.read = (io->curr.read_bytes - io->prev.read_bytes) / (1024.f * 1024.f);
|
|
|
|
|
io->diff.write = (io->curr.write_bytes - io->prev.write_bytes) / (1024.f * 1024.f);
|
|
|
|
|
if (io->last_update.time_since_epoch().count()) {
|
|
|
|
|
io->diff.read = (io->curr.read_bytes - io->prev.read_bytes) / (1024.f * 1024.f);
|
|
|
|
|
io->diff.write = (io->curr.write_bytes - io->prev.write_bytes) / (1024.f * 1024.f);
|
|
|
|
|
|
|
|
|
|
io->per_second.read = io->diff.read / timeDiffSecs;
|
|
|
|
|
io->per_second.write = io->diff.write / timeDiffSecs;
|
|
|
|
|
io->per_second.read = io->diff.read / time_diff.count();
|
|
|
|
|
io->per_second.write = io->diff.write / time_diff.count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastUpdate = now;
|
|
|
|
|
io->last_update = now;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|