diff --git a/conf/quality-config/pmd-ruleset.xml b/conf/quality-config/pmd-ruleset.xml index d24990b6245dea5ce8a40d06b836240078360bf8..033317f940a55ab1eb3610b27d2309aa90e374de 100644 --- a/conf/quality-config/pmd-ruleset.xml +++ b/conf/quality-config/pmd-ruleset.xml @@ -2,11 +2,37 @@ <ruleset name="TeeTime ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> - <description> - This ruleset checks my code for bad stuff - </description> + <description>This ruleset checks my code for bad stuff</description> - <rule ref="rulesets/internal/all-java.xml"></rule> +<!-- warning: if you reference a pmd rulesets xml file more than once, only the first rule is applied; so check for duplicates --> + +<!-- all java rules; on each new pmd release, check whether there were added new rulesets that need to be added here --> + <rule ref="rulesets/java/android.xml" /> + <rule ref="rulesets/java/basic.xml" /> + <rule ref="rulesets/java/braces.xml" /> + <rule ref="rulesets/java/clone.xml" /> + <rule ref="rulesets/java/codesize.xml" /> +<!-- <rule ref="rulesets/java/comments.xml" /> --> + <!-- <rule ref="rulesets/java/controversial.xml" /> --> + <rule ref="rulesets/java/coupling.xml" /> + <rule ref="rulesets/java/design.xml" /> + <rule ref="rulesets/java/empty.xml" /> + <rule ref="rulesets/java/finalizers.xml" /> + <rule ref="rulesets/java/imports.xml" /> + <rule ref="rulesets/java/j2ee.xml" /> + <rule ref="rulesets/java/javabeans.xml" /> + <rule ref="rulesets/java/junit.xml" /> + <rule ref="rulesets/java/logging-jakarta-commons.xml" /> + <rule ref="rulesets/java/logging-java.xml" /> + <rule ref="rulesets/java/migrating.xml" /> + <rule ref="rulesets/java/naming.xml" /> + <rule ref="rulesets/java/optimizations.xml" /> + <rule ref="rulesets/java/strictexception.xml" /> + <rule ref="rulesets/java/strings.xml" /> + <rule ref="rulesets/java/sunsecure.xml" /> + <rule ref="rulesets/java/typeresolution.xml" /> + <rule ref="rulesets/java/unnecessary.xml" /> + <rule ref="rulesets/java/unusedcode.xml" /> <rule ref="rulesets/ecmascript/basic.xml" /> <rule ref="rulesets/ecmascript/braces.xml" /> @@ -26,16 +52,20 @@ <priority>1</priority> </rule> - <rule ref="rulesets/java/optimizations.xml"> - <exclude name="LocalVariableCouldBeFinal" /> - </rule> - <rule ref="rulesets/java/comments.xml"> <exclude name="CommentRequired" /> </rule> - <rule ref="rulesets/java/naming.xml" name="VariableNamingConventions"> + <rule ref="rulesets/java/controversial.xml"> + <exclude name="AtLeastOneConstructor" /> + </rule> + + <rule ref="rulesets/java/naming.xml/VariableNamingConventions"> <priority>5</priority> </rule> + <rule ref="rulesets/java/optimizations.xml"> + <exclude name="LocalVariableCouldBeFinal" /> + </rule> + </ruleset> \ No newline at end of file diff --git a/src/main/java/kieker/analysis/stage/TimeReader.java b/src/main/java/kieker/analysis/stage/TimeReader.java index 30ec2b5577063225e951875c014f33c469793f16..9960c834900bca638ea3ae1a17b68bfb2c86c262 100644 --- a/src/main/java/kieker/analysis/stage/TimeReader.java +++ b/src/main/java/kieker/analysis/stage/TimeReader.java @@ -176,7 +176,7 @@ public final class TimeReader extends AbstractReaderPlugin { public void run() { if (this.infinite || (this.numberImpulses > 0)) { TimeReader.this.sendTimestampEvent(); - if (!this.infinite && (0 == --this.numberImpulses)) { // NOPMD + if (!this.infinite && (0 == --this.numberImpulses)) { TimeReader.this.impulseEmitLatch.countDown(); } } diff --git a/src/main/java/teetime/stage/io/DbReader.java b/src/main/java/teetime/stage/io/DbReader.java index d01fa8f0a53fc890078f4bdd018c3fef77c639b9..c9adbcd943efedeab8e0c65bb80cfa48d3d15446 100644 --- a/src/main/java/teetime/stage/io/DbReader.java +++ b/src/main/java/teetime/stage/io/DbReader.java @@ -59,7 +59,7 @@ public class DbReader extends ProducerStage<IMonitoringRecord> { public void onStarting() { try { Class.forName(this.driverClassname).newInstance(); - } catch (final Exception ex) { // NOPMD NOCS (IllegalCatchCheck) + } catch (final Exception ex) { throw new RuntimeException("DB driver registration failed. Perhaps the driver jar is missing?", ex); } } diff --git a/src/main/java/teetime/stage/io/TCPReader.java b/src/main/java/teetime/stage/io/TCPReader.java index ee2d8d5b8f96b9fa009dbce20f623c1852e946a0..8801dca2580e68f1e42fd1fd0b810d12f3d54825 100644 --- a/src/main/java/teetime/stage/io/TCPReader.java +++ b/src/main/java/teetime/stage/io/TCPReader.java @@ -197,7 +197,7 @@ public class TCPReader extends ProducerStage<IMonitoringRecord> { private final int port; private final ILookup<String> stringRegistry; - private volatile boolean terminated = false; // NOPMD + private volatile boolean terminated = false; private volatile Thread readerThread; public TCPStringReader(final int port, final ILookup<String> stringRegistry) { diff --git a/src/main/java/teetime/stage/kieker/className/MappingFileParser.java b/src/main/java/teetime/stage/kieker/className/MappingFileParser.java index a428056aa49840f02f889a5bd9d8c74a5c64317e..26765ce84bbe56c091eb4d85000f5a2609699c72 100644 --- a/src/main/java/teetime/stage/kieker/className/MappingFileParser.java +++ b/src/main/java/teetime/stage/kieker/className/MappingFileParser.java @@ -54,7 +54,7 @@ public class MappingFileParser { try { in = new BufferedReader(new InputStreamReader(inputStream, FSUtil.ENCODING)); String line; - while ((line = in.readLine()) != null) { // NOPMD (assign) + while ((line = in.readLine()) != null) { this.parseTextLine(line, classNameRegistry); } } catch (final IOException ex) { diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromBinaryFileCreator.java b/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromBinaryFileCreator.java index 17700c2a93973eb11c4a519e76711fa62ded3667..6d994e8f66ab26b0456f7665f492eebe79cfafbb 100644 --- a/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromBinaryFileCreator.java +++ b/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromBinaryFileCreator.java @@ -63,7 +63,7 @@ public class RecordFromBinaryFileCreator { final Class<?>[] typeArray = AbstractMonitoringRecord.typesForClass(clazz); // read record - final long loggingTimestamp = inputStream.readLong(); // NOPMD (must be read here!) + final long loggingTimestamp = inputStream.readLong(); final Object[] objectArray = new Object[typeArray.length]; int idx = -1; for (final Class<?> type : typeArray) { @@ -100,7 +100,7 @@ public class RecordFromBinaryFileCreator { objectArray[idx] = inputStream.readDouble(); } else if ((type == byte.class) || (type == Byte.class)) { objectArray[idx] = inputStream.readByte(); - } else if ((type == short.class) || (type == Short.class)) { // NOPMD (short) + } else if ((type == short.class) || (type == Short.class)) { objectArray[idx] = inputStream.readShort(); } else if ((type == boolean.class) || (type == Boolean.class)) { objectArray[idx] = inputStream.readBoolean(); diff --git a/src/main/java/teetime/stage/stringBuffer/util/KiekerHashMap.java b/src/main/java/teetime/stage/stringBuffer/util/KiekerHashMap.java index 22542a58e94def8f0df6da4500332b422c550d55..82667eed1ccd4e0a0579a55d2587391f9d1dbadb 100644 --- a/src/main/java/teetime/stage/stringBuffer/util/KiekerHashMap.java +++ b/src/main/java/teetime/stage/stringBuffer/util/KiekerHashMap.java @@ -99,8 +99,8 @@ public class KiekerHashMap { * StringBuffer entry. */ private static final class HashEntry extends SoftReference<String> { - final int hash; // NOPMD NOCS (package visible for inner class) - final HashEntry next; // NOPMD NOCS (package visible for inner class) + final int hash; + final HashEntry next; protected HashEntry(final String value, final int hash, final HashEntry next) { super(value); @@ -277,7 +277,7 @@ public class KiekerHashMap { newTable[lastIdx] = lastRun; // Clone all remaining nodes - for (HashEntry p = e; p != lastRun; p = p.next) { // NOPMD (no equals meant here) + for (HashEntry p = e; p != lastRun; p = p.next) { final int k = p.hash & sizeMask; final HashEntry n = newTable[k]; newTable[k] = new HashEntry(p.get(), p.hash, n); diff --git a/src/main/java/util/KiekerLoadDriver.java b/src/main/java/util/KiekerLoadDriver.java index 65795567b3a578a10f2d459991a89dedd8836672..d6509d8016ba125a7f7a4c92cf29fdcbca86d744 100644 --- a/src/main/java/util/KiekerLoadDriver.java +++ b/src/main/java/util/KiekerLoadDriver.java @@ -173,7 +173,7 @@ public class KiekerLoadDriver { long stop_ns = System.nanoTime(); this.timings[i] = stop_ns - start_ns; if ((i % 100000) == 0) { - System.out.println(i); // NOPMD (System.out) + System.out.println(i); } // System.out.println("writtenBytes (record): " + writtenBytes); recordBuffer.clear(); diff --git a/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java b/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java index 52105427b358d1f6e97fc709eb0f5553283f3ac8..afd8226e3c0a964f4b31339e42364a745a1bcd5f 100644 --- a/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java +++ b/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java @@ -25,8 +25,6 @@ public class ChwHomeComparisonMethodcallWithPorts extends ProfiledPerformanceAss PerformanceResult test1 = performanceResults .get("testWithManyObjects(teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test)"); - PerformanceResult test9 = performanceResults - .get("testWithManyObjects(teetime.examples.experiment09.MethodCallThoughputTimestampAnalysis9Test)"); PerformanceResult test15 = performanceResults .get("testWithManyObjects(teetime.examples.experiment15.MethodCallThoughputTimestampAnalysis15Test)"); PerformanceResult test16a = performanceResults @@ -44,36 +42,29 @@ public class ChwHomeComparisonMethodcallWithPorts extends ProfiledPerformanceAss PerformanceResult test19c = performanceResults .get("testWithManyObjectsAnd4Threads(teetime.examples.experiment19.MethodCallThoughputTimestampAnalysis19Test)"); - double value9 = (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5); double value15 = (double) test15.quantiles.get(0.5) / test1.quantiles.get(0.5); double value17 = (double) test17.quantiles.get(0.5) / test1.quantiles.get(0.5); - System.out.println("value9: " + value9); System.out.println("value15: " + value15); System.out.println("value17: " + value17); // until 25.06.2014 (incl.) - // assertEquals(22, (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5), 2.1); // assertEquals(44, (double) test15.quantiles.get(0.5) / test1.quantiles.get(0.5), 4.1); // assertEquals(39, (double) test17.quantiles.get(0.5) / test1.quantiles.get(0.5), 4.1); // since 26.06.2014 (incl.) - // assertEquals(36, value9, 2.1); // +14 // assertEquals(44, value15, 4.1); // +0 // assertEquals(53, value17, 4.1); // +14 // // since 04.07.2014 (incl.) - // assertEquals(42, value9, 2.1); // +6 // assertEquals(44, value15, 4.1); // +0 // assertEquals(53, value17, 4.1); // +0 // since 11.08.2014 (incl.) - // assertEquals(42, value9, 2.1); // +6 // assertEquals(44, value15, 4.1); // +0 // assertEquals(53, value17, 4.1); // +0 // since 31.08.2014 (incl.) - assertEquals(44, value9, 2.1); // ?? assertEquals(68, value15, 4.1); // ?? assertEquals(75, value17, 4.1); // ?? diff --git a/src/performancetest/java/teetime/examples/ChwWorkComparisonMethodcallWithPorts.java b/src/performancetest/java/teetime/examples/ChwWorkComparisonMethodcallWithPorts.java index df569b2d7a480d6766dd527f9bfe06960eac8bfb..93fbd19d584827f1ded61db4c8dc4617a29b8a42 100644 --- a/src/performancetest/java/teetime/examples/ChwWorkComparisonMethodcallWithPorts.java +++ b/src/performancetest/java/teetime/examples/ChwWorkComparisonMethodcallWithPorts.java @@ -25,8 +25,6 @@ public class ChwWorkComparisonMethodcallWithPorts extends ProfiledPerformanceAss PerformanceResult test1 = performanceResults .get("testWithManyObjects(teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test)"); - PerformanceResult test9 = performanceResults - .get("testWithManyObjects(teetime.examples.experiment09.MethodCallThoughputTimestampAnalysis9Test)"); PerformanceResult test15 = performanceResults .get("testWithManyObjects(teetime.examples.experiment15.MethodCallThoughputTimestampAnalysis15Test)"); PerformanceResult test17 = performanceResults @@ -38,36 +36,29 @@ public class ChwWorkComparisonMethodcallWithPorts extends ProfiledPerformanceAss PerformanceResult test19c = performanceResults .get("testWithManyObjectsAnd4Threads(teetime.examples.experiment19.MethodCallThoughputTimestampAnalysis19Test)"); - double value9 = (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5); double value15 = (double) test15.quantiles.get(0.5) / test1.quantiles.get(0.5); double value17 = (double) test17.quantiles.get(0.5) / test1.quantiles.get(0.5); - System.out.println("value9: " + value9); System.out.println("value15: " + value15); System.out.println("value17: " + value17); // until 25.06.2014 (incl.) - // assertEquals(22, (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5), 2.1); // assertEquals(44, (double) test15.quantiles.get(0.5) / test1.quantiles.get(0.5), 4.1); // assertEquals(39, (double) test17.quantiles.get(0.5) / test1.quantiles.get(0.5), 4.1); // since 26.06.2014 (incl.) - // assertEquals(36, value9, 2.1); // +14 // assertEquals(44, value15, 4.1); // +0 // assertEquals(53, value17, 4.1); // +14 // since 04.07.2014 (incl.) - // assertEquals(42, value9, 2.1); // +6 // assertEquals(44, value15, 4.1); // +0 // assertEquals(53, value17, 4.1); // +0 // since 27.08.2014 (incl.) - // assertEquals(77, value9, 2.1); // +35 // assertEquals(44, value15, 4.1); // +0 // assertEquals(53, value17, 4.1); // +0 // since 14.10.2014 (incl.) - assertEquals(67, value9, 3.1); // -10 assertEquals(36, value15, 4.1); // -8 assertEquals(46, value17, 4.1); // -7 diff --git a/src/performancetest/java/teetime/examples/experiment09/AbstractPerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment09/AbstractPerformanceCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..784024b9044b2f437499162fe95ced5d078b2329 --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment09/AbstractPerformanceCheck.java @@ -0,0 +1,22 @@ +package teetime.examples.experiment09; + +import teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test; +import util.test.MeasurementRepository; +import util.test.PerformanceResult; +import util.test.PerformanceTest; +import util.test.ProfiledPerformanceAssertion; + +abstract class AbstractPerformanceCheck extends ProfiledPerformanceAssertion { + + protected PerformanceResult test01; + protected PerformanceResult test09; + + @Override + public void check() { + String testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis1Test.class, "testWithManyObjects"); + test01 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier); + testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis9Test.class, "testWithManyObjects"); + test09 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier); + } + +} diff --git a/src/performancetest/java/teetime/examples/experiment09/ChwHomePerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment09/ChwHomePerformanceCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..248925bd7af978a6719b83e2678a90615388cd33 --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment09/ChwHomePerformanceCheck.java @@ -0,0 +1,31 @@ +package teetime.examples.experiment09; + +import static org.junit.Assert.assertEquals; + +public class ChwHomePerformanceCheck extends AbstractPerformanceCheck { + + @Override + public String getCorrespondingPerformanceProfile() { + return "ChwHome"; + } + + @Override + public void check() { + super.check(); + + double medianSpeedup = (double) test09.quantiles.get(0.5) / test01.quantiles.get(0.5); + + System.out.println("medianSpeedup (09): " + medianSpeedup); + + // until 25.06.2014 (incl.) + // assertEquals(22, (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5), 2.1); + // since 26.06.2014 (incl.) + // assertEquals(36, value9, 2.1); // +14 + // // since 04.07.2014 (incl.) + // assertEquals(42, value9, 2.1); // +6 + // since 11.08.2014 (incl.) + // assertEquals(42, value9, 2.1); // +6 + // since 31.08.2014 (incl.) + assertEquals(44, medianSpeedup, 2.1); // ?? + } +} diff --git a/src/performancetest/java/teetime/examples/experiment09/ChwWorkPerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment09/ChwWorkPerformanceCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..1f5e65eb9c3ffdac0f89ef4690547342864af34f --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment09/ChwWorkPerformanceCheck.java @@ -0,0 +1,31 @@ +package teetime.examples.experiment09; + +import static org.junit.Assert.assertEquals; + +public class ChwWorkPerformanceCheck extends AbstractPerformanceCheck { + + @Override + public String getCorrespondingPerformanceProfile() { + return "ChwWork"; + } + + @Override + public void check() { + super.check(); + + double medianSpeedup = (double) test09.quantiles.get(0.5) / test01.quantiles.get(0.5); + + System.out.println("medianSpeedup (09): " + medianSpeedup); + + // until 25.06.2014 (incl.) + // assertEquals(22, (double) test9.quantiles.get(0.5) / test1.quantiles.get(0.5), 2.1); + // since 26.06.2014 (incl.) + // assertEquals(36, value9, 2.1); // +14 + // since 04.07.2014 (incl.) + // assertEquals(42, value9, 2.1); // +6 + // since 27.08.2014 (incl.) + // assertEquals(77, value9, 2.1); // +35 + // since 14.10.2014 (incl.) + assertEquals(67, medianSpeedup, 3.1); // -10 + } +} diff --git a/src/performancetest/java/teetime/examples/experiment09/MethodCallThoughputTimestampAnalysis9Test.java b/src/performancetest/java/teetime/examples/experiment09/MethodCallThoughputTimestampAnalysis9Test.java index 489f6e4a78494ca24b5792f7d1b2859f295d7e3b..4267330d592daa97fffe7ae6ae159061b9f71dd2 100644 --- a/src/performancetest/java/teetime/examples/experiment09/MethodCallThoughputTimestampAnalysis9Test.java +++ b/src/performancetest/java/teetime/examples/experiment09/MethodCallThoughputTimestampAnalysis9Test.java @@ -15,11 +15,16 @@ ***************************************************************************/ package teetime.examples.experiment09; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; +import teetime.examples.experiment10.ChwHomePerformanceCheck; +import teetime.examples.experiment10.ChwWorkPerformanceCheck; import teetime.util.ConstructorClosure; import teetime.util.TimestampObject; import util.test.PerformanceTest; +import util.test.ProfiledPerformanceAssertion; /** * @author Christian Wulf @@ -28,6 +33,18 @@ import util.test.PerformanceTest; */ public class MethodCallThoughputTimestampAnalysis9Test extends PerformanceTest { + @BeforeClass + public static void beforeClass() { + PERFORMANCE_CHECK_PROFILE_REPOSITORY.register(MethodCallThoughputTimestampAnalysis9Test.class, new ChwWorkPerformanceCheck()); + PERFORMANCE_CHECK_PROFILE_REPOSITORY.register(MethodCallThoughputTimestampAnalysis9Test.class, new ChwHomePerformanceCheck()); + }; + + @AfterClass + public static void afterClass() { + ProfiledPerformanceAssertion performanceCheckProfile = PERFORMANCE_CHECK_PROFILE_REPOSITORY.get(MethodCallThoughputTimestampAnalysis9Test.class); + performanceCheckProfile.check(); + }; + @Test public void testWithManyObjects() { System.out.println("Testing teetime (mc) with NUM_OBJECTS_TO_CREATE=" + NUM_OBJECTS_TO_CREATE + ", NUM_NOOP_FILTERS=" diff --git a/src/performancetest/java/teetime/examples/experiment10/AbstractPerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment10/AbstractPerformanceCheck.java index 3a4e75a1e8791d2efad40971febde87366cf8f3e..495b74cadd03319e8e2dc1bd550077172edfdbe0 100644 --- a/src/performancetest/java/teetime/examples/experiment10/AbstractPerformanceCheck.java +++ b/src/performancetest/java/teetime/examples/experiment10/AbstractPerformanceCheck.java @@ -6,7 +6,7 @@ import util.test.PerformanceResult; import util.test.PerformanceTest; import util.test.ProfiledPerformanceAssertion; -public abstract class AbstractPerformanceCheck extends ProfiledPerformanceAssertion { +abstract class AbstractPerformanceCheck extends ProfiledPerformanceAssertion { protected PerformanceResult test01; protected PerformanceResult test10; diff --git a/src/performancetest/java/teetime/examples/experiment14/AbstractPerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment14/AbstractPerformanceCheck.java index 86b158afdb987ea1b597ea348a8cca02406cd2de..7976d16614ef88a53a34c3031a4471b6a6c98eae 100644 --- a/src/performancetest/java/teetime/examples/experiment14/AbstractPerformanceCheck.java +++ b/src/performancetest/java/teetime/examples/experiment14/AbstractPerformanceCheck.java @@ -6,7 +6,7 @@ import util.test.PerformanceResult; import util.test.PerformanceTest; import util.test.ProfiledPerformanceAssertion; -public abstract class AbstractPerformanceCheck extends ProfiledPerformanceAssertion { +abstract class AbstractPerformanceCheck extends ProfiledPerformanceAssertion { protected PerformanceResult test01; protected PerformanceResult test14;