Skip to content

Commit 0a2266a

Browse files
[log] Set duration to 0 when next time stamp is smaller
Due to the circular buffer, when overwriting previously logged data, the iteration duration could be highly negative. Set it to zero in that case.
1 parent 56f167d commit 0a2266a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/log.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ void Log::saveVector(std::string &fileName, std::string &suffix,
223223
dt = StoredData_.timestamp[0] -
224224
StoredData_.timestamp[profileLog_.length - 1];
225225
} else
226-
dt = StoredData_.timestamp[k] - StoredData_.timestamp[k - 1];
226+
dt = std::max(0., StoredData_.timestamp[k] -
227+
StoredData_.timestamp[k - 1]);
227228
writeToBinaryFile(aof, StoredData_.timestamp[i], dt, avector, idx, size);
228229
idx = (idx + size) % N;
229230
}

0 commit comments

Comments
 (0)