Treat -1 as the invalid microsecond duration value, not 0

* Some functions can be so quick that they register as a duration of 0.
  This is expected and we should not end up omitting it when importing
  or exporting because we think it was missing. As a 64-bit value,
  losing a bit for signedness is not a problem.
This commit is contained in:
baldurk
2018-02-12 16:59:55 +00:00
parent 770903c9dd
commit 80bb034315
3 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -217,8 +217,9 @@ conservative size estimate was used on creation to avoid seeking to fix-up the s
DOCUMENT(R"(The duration in microseconds that this chunk took. This is the time for the actual
work, not the serialising.
Since 0 is a possible value for this (for extremely fast calls), -1 is the invalid/not present value.
)");
uint64_t durationMicro = 0;
int64_t durationMicro = -1;
DOCUMENT("The point in time when this chunk was recorded, in microseconds since program start.");
uint64_t timestampMicro = 0;
+1 -1
View File
@@ -354,7 +354,7 @@ static ReplayStatus Structured2XML(const char *filename, const RDCFile &file, ui
xChunk.append_attribute("threadID") = chunk->metadata.threadID;
if(chunk->metadata.timestampMicro)
xChunk.append_attribute("timestamp") = chunk->metadata.timestampMicro;
if(chunk->metadata.durationMicro)
if(chunk->metadata.durationMicro >= 0)
xChunk.append_attribute("duration") = chunk->metadata.durationMicro;
if(!chunk->metadata.callstack.empty())
{
+1 -1
View File
@@ -431,7 +431,7 @@ void Serialiser<SerialiserMode::Writing>::WriteStructuredFile(const SDFile &file
if(m_ChunkMetadata.threadID != 0)
m_ChunkFlags |= ChunkThreadID;
if(m_ChunkMetadata.durationMicro != 0)
if(m_ChunkMetadata.durationMicro >= 0)
m_ChunkFlags |= ChunkDuration;
if(m_ChunkMetadata.timestampMicro != 0)