Example #1
0
void Statistics::endFrame() {
	setValue(frameDurationCounter, frameTimer.getMilliseconds());

	{ // IO
		static Util::Timer ioTimer;
		static size_t lastBytesRead = 0;
		static size_t lastBytesWritten = 0;

		const uint64_t duration = ioTimer.getNanoseconds();
		// Update every second.
		if(duration > 1000000000) {
			const size_t bytesRead = Util::Utils::getIOBytesRead();
			const size_t bytesWritten = Util::Utils::getIOBytesWritten();

			const double MebiPerSecond = 1024.0 * 1024.0 * 1.0e-9 * static_cast<double>(duration);
			const double readRate = static_cast<double>(bytesRead - lastBytesRead) / MebiPerSecond;
			const double writeRate = static_cast<double>(bytesWritten - lastBytesWritten) / MebiPerSecond;

			ioTimer.reset();
			lastBytesRead = bytesRead;
			lastBytesWritten = bytesWritten;

			setValue(ioRateReadCounter, readRate);
			setValue(ioRateWriteCounter, writeRate);
		}
	}

	pushEvent(EVENT_TYPE_FRAME_END, 1);
}
Example #2
0
int test_statistics() {
	std::ofstream output("test_statistics.tsv");
	output << "class\tnumEventTypes\tnumEventsOverall\tduration\n";
	Util::Timer timer;
	for(uint32_t numRuns = 1; numRuns < 5; ++numRuns) {
		for(uint32_t numEventsOverall = 1; numEventsOverall <= 1000000; numEventsOverall *= 10) {
			for(uint32_t numEventTypes = 1; numEventTypes <= 32; numEventTypes *= 2) {
				timer.reset();
				testStatistics(numEventTypes, numEventsOverall);
				timer.stop();
				output << "Statistics\t" << numEventTypes << '\t' << numEventsOverall << '\t' << timer.getNanoseconds() << '\n';
				timer.reset();
				testProfiler(numEventTypes, numEventsOverall);
				timer.stop();
				output << "Profiler\t" << numEventTypes << '\t' << numEventsOverall << '\t' << timer.getNanoseconds() << '\n';
			}
		}
	}
	return EXIT_SUCCESS;
}