aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2021-08-08 12:07:36 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2021-08-08 12:07:36 +0700
commitdd712993651f9f314aa6cb9a58fbcce90a175868 (patch)
treeff6b129170f3da9defcb4391b10f49e29831dfef /tests
parente634db03482c8620f2ce39484501bb23e0a74471 (diff)
downloadaspectj-dd712993651f9f314aa6cb9a58fbcce90a175868.tar.gz
aspectj-dd712993651f9f314aa6cb9a58fbcce90a175868.zip
Improve flaky test in Ajc1612Tests further
By using System.nanoTime() instead of currentTimeMillis(), the flakiness even with the original 10,000 rounds is significantly lower than before. Making my IDE repeat the test until failure, it took on average 150 runs to make it fail. So, the more accurate timing helps. With 100,000 rounds, it was even more stable, but eventually I could make it fail. With 1,000,000 rounds however, even running the test 500x could not make it fail. So for all practical purposes, I think the test is reasonably stable now. Closes #83. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs1612/pr356612/AnnoBinding.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/bugs1612/pr356612/AnnoBinding.java b/tests/bugs1612/pr356612/AnnoBinding.java
index fd47c6785..609866fc3 100644
--- a/tests/bugs1612/pr356612/AnnoBinding.java
+++ b/tests/bugs1612/pr356612/AnnoBinding.java
@@ -10,19 +10,19 @@ import org.aspectj.lang.reflect.FieldSignature;
public class AnnoBinding {
public static void main(String[] argv) {
- long stime = System.currentTimeMillis();
- // 10,000 or 100,000 rounds are too quick, making the test flaky
+ long stime = System.nanoTime();
+ // 10,000 or 100,000 rounds are too quick, making the test flaky on rare occasions
final int ROUNDS = 1000 * 1000;
for (int i = 0; i < ROUNDS; i++) {
runOne();
}
- long etime = System.currentTimeMillis();
+ long etime = System.nanoTime();
long manual = (etime - stime);
- stime = System.currentTimeMillis();
+ stime = System.nanoTime();
for (int i = 0; i < ROUNDS; i++) {
runTwo();
}
- etime = System.currentTimeMillis();
+ etime = System.nanoTime();
long woven = (etime - stime);
System.out.println("woven=" + woven + " manual=" + manual);
if (woven > manual) {