Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,8 @@ public boolean diarize(String line) {

@Override
public DateTimeStamp getTimeOfFirstEvent() {
if (timeOfFirstEvent == null)
timeOfFirstEvent = new DateTimeStamp(0.0d);
return timeOfFirstEvent;
// Keep the fallback transient so a timestamp found on a later line can still be recorded.
return timeOfFirstEvent == null ? new DateTimeStamp(0.0d) : timeOfFirstEvent;
Comment thread
karianna marked this conversation as resolved.
Resolved
}

private void timeOfFirstEvent(String line) {
Expand Down Expand Up @@ -1047,4 +1046,5 @@ private void setGCCause(String gcCause) {
}
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package com.microsoft.gctoolkit.parser;

import com.microsoft.gctoolkit.parser.jvm.PreUnifiedDiarizer;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class PreUnifiedDiarizerTest {

@Test
void earlyTimestampLookupDoesNotPreventRecordingFirstEvent() {
PreUnifiedDiarizer diarizer = new PreUnifiedDiarizer();
assertEquals(0.0, diarizer.getTimeOfFirstEvent().toSeconds());

diarizer.diarize("1.250: [GC (Allocation Failure) 100K->50K(200K), 0.001 secs]");
assertEquals(1.250, diarizer.getTimeOfFirstEvent().toSeconds());
assertEquals(1.250, diarizer.getDiary().getTimeOfFirstEvent().toSeconds());

diarizer.diarize("2.500: [GC (Allocation Failure) 100K->50K(200K), 0.001 secs]");
assertEquals(1.250, diarizer.getTimeOfFirstEvent().toSeconds());
assertEquals(1.250, diarizer.getDiary().getTimeOfFirstEvent().toSeconds());
}
}
Loading