MCPcopy Create free account
hub / github.com/chrxh/alien / measureTPS

Method measureTPS

source/EngineImpl/EngineWorker.cpp:557–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

555}
556
557void EngineWorker::measureTPS()
558{
559 if (_isSimulationRunning.load()) {
560 auto timepoint = std::chrono::steady_clock::now();
561 if (!_measureTimepoint) {
562 _measureTimepoint = timepoint;
563 } else {
564 int duration = static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(timepoint - *_measureTimepoint).count());
565 if (duration > 199) {
566 _measureTimepoint = timepoint;
567 if (duration < 350) {
568 _tps.store(toFloat(_timestepsSinceMeasurement) * 5 * 200 / duration);
569 } else {
570 _tps.store(1000.0f / duration);
571 }
572 _timestepsSinceMeasurement = 0;
573 }
574 }
575 ++_timestepsSinceMeasurement;
576 } else {
577 _tps.store(0);
578 }
579}
580
581void EngineWorker::slowdownTPS()
582{

Callers

nothing calls this directly

Calls 2

toFloatFunction · 0.85
loadMethod · 0.80

Tested by

no test coverage detected