logging: check if duration is enabled before checking if it has expired
If we check if log_duration is enabled before checking if it has expired
we can save some math and comparison instructions on every log write.
@@ -58,7 +58,7 @@ void *logging(void *params_void){
elapsedLog = now - log_start;
logArray.push_back({fps, cpuLoadLog, gpuLoadLog, elapsedLog});
- if ((elapsedLog) >= params->log_duration * 1000000 && params->log_duration)
+ if (params->log_duration && (elapsedLog) >= params->log_duration * 1000000)
loggingOn = false;
else
this_thread::sleep_for(chrono::milliseconds(log_period));
