-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,246 additions
and
226 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
IT/src/main/java/com/microsoft/gctoolkit/integration/aggregation/CMSCycleAggregation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.microsoft.gctoolkit.integration.aggregation; | ||
|
||
import com.microsoft.gctoolkit.aggregator.Aggregation; | ||
import com.microsoft.gctoolkit.aggregator.Collates; | ||
|
||
@Collates(CMSCycleAggregator.class) | ||
public class CMSCycleAggregation extends Aggregation { | ||
|
||
private int initialMark = 0; | ||
private int remark = 0; | ||
private int concurrentEvent = 0; | ||
|
||
public void initialMark() { | ||
initialMark++; | ||
} | ||
|
||
public void remark() { | ||
remark++; | ||
} | ||
|
||
public void concurrentEvent() { | ||
concurrentEvent++; | ||
} | ||
|
||
public int getInitialMark() { return initialMark; } | ||
public int getRemark() { return remark; } | ||
public int getConcurrentEvent() { return concurrentEvent; } | ||
|
||
@Override | ||
public boolean hasWarning() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
IT/src/main/java/com/microsoft/gctoolkit/integration/aggregation/CMSCycleAggregator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.microsoft.gctoolkit.integration.aggregation; | ||
|
||
import com.microsoft.gctoolkit.aggregator.Aggregates; | ||
import com.microsoft.gctoolkit.aggregator.Aggregator; | ||
import com.microsoft.gctoolkit.aggregator.EventSource; | ||
import com.microsoft.gctoolkit.event.generational.CMSConcurrentEvent; | ||
import com.microsoft.gctoolkit.event.generational.CMSRemark; | ||
import com.microsoft.gctoolkit.event.generational.InitialMark; | ||
|
||
@Aggregates({EventSource.GENERATIONAL}) | ||
public class CMSCycleAggregator extends Aggregator<CMSCycleAggregation> { | ||
|
||
private InitialMark lastInitialMark = null; | ||
private CMSRemark lastRemark = null; | ||
public CMSCycleAggregator(CMSCycleAggregation results) { | ||
super(results); | ||
register(InitialMark.class, this::count); | ||
register(CMSRemark.class, this::count); | ||
register(CMSConcurrentEvent.class, this::count); | ||
} | ||
|
||
public void count(InitialMark event) { | ||
if ( event.equals(lastInitialMark)) return; | ||
lastInitialMark = event; | ||
aggregation().initialMark(); | ||
} | ||
|
||
public void count(CMSRemark event) { | ||
System.out.println(event.toString()); | ||
if ( event.equals(lastRemark)) return; | ||
lastRemark = event; | ||
aggregation().remark(); | ||
} | ||
|
||
public void count(CMSConcurrentEvent event) { | ||
aggregation().concurrentEvent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
IT/src/test/java/com/microsoft/gctoolkit/integration/CMSEventsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.microsoft.gctoolkit.integration; | ||
|
||
import com.microsoft.gctoolkit.GCToolKit; | ||
import com.microsoft.gctoolkit.integration.aggregation.CMSCycleAggregation; | ||
import com.microsoft.gctoolkit.integration.io.TestLogFile; | ||
import com.microsoft.gctoolkit.io.GCLogFile; | ||
import com.microsoft.gctoolkit.io.SingleGCLogFile; | ||
import com.microsoft.gctoolkit.jvm.JavaVirtualMachine; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
@Tag("modulePath") | ||
public class CMSEventsTest { | ||
@Test | ||
public void testMain() { | ||
Path path = new TestLogFile("preunified/cms/parnew/details/scavangeBeforeRemarkWithReference.log").getFile().toPath(); | ||
analyze(path.toString()); | ||
} | ||
|
||
public void analyze(String gcLogFile) { | ||
/** | ||
* GC log files can come in one of two types: single or series of rolling logs. | ||
* In this sample, we load a single log file. | ||
* The log files can be either in text, zip, or gzip format. | ||
*/ | ||
GCLogFile logFile = new SingleGCLogFile(Path.of(gcLogFile)); | ||
GCToolKit gcToolKit = new GCToolKit(); | ||
|
||
/** | ||
* This call will load all implementations of Aggregator that have been declared in module-info.java. | ||
* This mechanism makes use of Module SPI. | ||
*/ | ||
gcToolKit.loadAggregationsFromServiceLoader(); | ||
|
||
/** | ||
* The JavaVirtualMachine contains the aggregations as filled out by the Aggregators. | ||
* It also contains configuration information about how the JVM was configured for the runtime. | ||
*/ | ||
JavaVirtualMachine machine = null; | ||
try { | ||
machine = gcToolKit.analyze(logFile); | ||
} catch (IOException e) { | ||
fail(e.getMessage()); | ||
} | ||
|
||
machine.getAggregation(CMSCycleAggregation.class).ifPresent(cmsCycleCounts -> { | ||
Assertions.assertEquals( 1, cmsCycleCounts.getInitialMark(), "Initial Mark events count"); | ||
//Assertions.assertEquals( 1, cmsCycleCounts.getRemark(), "Remark events count"); | ||
//Assertions.assertEquals( 4, cmsCycleCounts.getConcurrentEvent(), "concurrent phase events count"); | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.