MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / getStats

Method getStats

runtime/RuntimeLogger.cc:139–231  ·  view source on GitHub ↗

Documentation in NanoLog.h

Source from the content-addressed store, hash-verified

137
138// Documentation in NanoLog.h
139std::string
140RuntimeLogger::getStats() {
141 std::ostringstream out;
142 char buffer[1024];
143 // Leaks abstraction, but basically flush so we get all the time
144 uint64_t start = PerfUtils::Cycles::rdtsc();
145 fdatasync(nanoLogSingleton.outputFd);
146 uint64_t stop = PerfUtils::Cycles::rdtsc();
147 nanoLogSingleton.cyclesDiskIO_upperBound += (stop - start);
148
149 double outputTime =
150 PerfUtils::Cycles::toSeconds(nanoLogSingleton.cyclesDiskIO_upperBound);
151 double compressTime =
152 PerfUtils::Cycles::toSeconds(nanoLogSingleton.cyclesCompressing);
153 double workTime = outputTime + compressTime;
154
155 double totalBytesWrittenDouble = static_cast<double>(
156 nanoLogSingleton.totalBytesWritten);
157 double totalBytesReadDouble = static_cast<double>(
158 nanoLogSingleton.totalBytesRead);
159 double padBytesWrittenDouble = static_cast<double>(
160 nanoLogSingleton.padBytesWritten);
161 double numEventsProcessedDouble = static_cast<double>(
162 nanoLogSingleton.logsProcessed);
163
164 snprintf(buffer, 1024,
165 "\r\nWrote %lu events (%0.2lf MB) in %0.3lf seconds "
166 "(%0.3lf seconds spent compressing)\r\n",
167 nanoLogSingleton.logsProcessed,
168 totalBytesWrittenDouble / 1.0e6,
169 workTime,
170 compressTime);
171 out << buffer;
172
173 snprintf(buffer, 1024,
174 "There were %u file flushes and the final sync time was %lf sec\r\n",
175 nanoLogSingleton.numAioWritesCompleted,
176 PerfUtils::Cycles::toSeconds(stop - start));
177 out << buffer;
178
179 double secondsAwake =
180 PerfUtils::Cycles::toSeconds(nanoLogSingleton.cyclesActive);
181 double secondsThreadHasBeenAlive = PerfUtils::Cycles::toSeconds(
182 PerfUtils::Cycles::rdtsc() - nanoLogSingleton.cycleAtThreadStart);
183 snprintf(buffer, 1024,
184 "Compression Thread was active for %0.3lf out of %0.3lf seconds "
185 "(%0.2lf %%)\r\n",
186 secondsAwake,
187 secondsThreadHasBeenAlive,
188 100.0 * secondsAwake / secondsThreadHasBeenAlive);
189 out << buffer;
190
191 snprintf(buffer, 1024,
192 "On average, that's\r\n\t%0.2lf MB/s or "
193 "%0.2lf ns/byte w/ processing\r\n",
194 (totalBytesWrittenDouble / 1.0e6) / (workTime),
195 (workTime * 1.0e9) / totalBytesWrittenDouble);
196 out << buffer;

Callers

nothing calls this directly

Calls 1

rdtscFunction · 0.85

Tested by

no test coverage detected