This directory contains JMH (Java Microbenchmark Harness) benchmarks to measure the performance improvements in the optimized XmlPlexusConfiguration implementation.
The benchmarks compare the old implementation (XmlPlexusConfigurationOld) with the new optimized implementation (XmlPlexusConfiguration) across several key performance metrics:
Compile the test classes:
mvn test-compile -pl impl/maven-xml
Run all benchmarks:
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \ -Dexec.classpathScope=test \ -Dexec.args="org.apache.maven.internal.xml.*Benchmark" \ -pl impl/maven-xml
Constructor Performance:
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \ -Dexec.classpathScope=test \ -Dexec.args="XmlPlexusConfigurationBenchmark.constructor.*" \ -pl impl/maven-xml
Memory Allocation:
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \ -Dexec.classpathScope=test \ -Dexec.args="XmlPlexusConfigurationMemoryBenchmark" \ -pl impl/maven-xml
Thread Safety:
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \ -Dexec.classpathScope=test \ -Dexec.args="XmlPlexusConfigurationConcurrencyBenchmark" \ -pl impl/maven-xml
Generate detailed reports:
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \ -Dexec.classpathScope=test \ -Dexec.args="-rf json -rff benchmark-results.json org.apache.maven.internal.xml.*Benchmark" \ -pl impl/maven-xml
Profile memory allocation:
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \ -Dexec.classpathScope=test \ -Dexec.args="-prof gc XmlPlexusConfigurationMemoryBenchmark" \ -pl impl/maven-xml
Profile with async profiler (if available):
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \ -Dexec.classpathScope=test \ -Dexec.args="-prof async:output=flamegraph XmlPlexusConfigurationBenchmark" \ -pl impl/maven-xml
Based on the optimizations implemented, you should see:
Here are real performance measurements from the benchmark suite:
Benchmark Mode Cnt Score Error Units XmlPlexusConfigurationBenchmark.constructorNewSimple avgt 3 4.666 ± 7.721 ns/op XmlPlexusConfigurationBenchmark.constructorOldSimple avgt 3 41.361 ± 14.438 ns/op
Result: 8.9x faster (88% improvement)
Benchmark Mode Cnt Score Error Units XmlPlexusConfigurationBenchmark.constructorNewComplex avgt 3 4.887 ± 15.716 ns/op XmlPlexusConfigurationBenchmark.constructorOldComplex avgt 3 657.163 ± 94.225 ns/op
Result: 134x faster (99.3% improvement)
These results demonstrate the dramatic performance benefits of the optimization, especially for complex XML structures where the old implementation's deep copying becomes extremely expensive.
Out of Memory Errors:
-Dexec.args="-jvmArgs -Xmx4g"-Dexec.args="-wi 1 -i 3"Long Execution Times:
-Dexec.args="-w 1s -r 1s"When adding new benchmarks: