diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-08-08 12:09:52 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-08-08 12:09:52 +0700 |
commit | e18f5dd41b3f390883d8d127b086a3f58f929e7e (patch) | |
tree | 4bbf40730d7727c9547d49a8825743f6081b0327 /tests/bugs1612 | |
parent | dd712993651f9f314aa6cb9a58fbcce90a175868 (diff) | |
download | aspectj-e18f5dd41b3f390883d8d127b086a3f58f929e7e.tar.gz aspectj-e18f5dd41b3f390883d8d127b086a3f58f929e7e.zip |
Refactor AnnoBinding test class used by Ajc1612Tests some more
Improve improved general logging, error messages, variable naming and
indentation, making the code of class AnnoBinding a bit more readable.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/bugs1612')
-rw-r--r-- | tests/bugs1612/pr356612/AnnoBinding.java | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/tests/bugs1612/pr356612/AnnoBinding.java b/tests/bugs1612/pr356612/AnnoBinding.java index 609866fc3..d03131615 100644 --- a/tests/bugs1612/pr356612/AnnoBinding.java +++ b/tests/bugs1612/pr356612/AnnoBinding.java @@ -17,19 +17,24 @@ public class AnnoBinding { runOne(); } long etime = System.nanoTime(); - long manual = (etime - stime); + long reflective = (etime - stime); stime = System.nanoTime(); for (int i = 0; i < ROUNDS; i++) { runTwo(); } etime = System.nanoTime(); - long woven = (etime - stime); - System.out.println("woven=" + woven + " manual=" + manual); - if (woven > manual) { - throw new RuntimeException("woven=" + woven + " manual=" + manual); + long bound = (etime - stime); + String result = String.format("bound = %,d, reflective = %,d", bound, reflective); + System.out.println(result); + if (bound > reflective) { + throw new RuntimeException( + "Accessing annotation via bound parameter should be faster than reflective access: " + result + ); } - if (X.a != X.b) { - throw new RuntimeException("a=" + X.a + " b=" + X.b); + if (X.sumReflective != X.sumBound) { + throw new RuntimeException( + String.format("Sums of @Marker message lengths should be equal: reflective = %,d, bound = %,d", X.sumReflective, X.sumBound) + ); } } @@ -50,21 +55,18 @@ public class AnnoBinding { } aspect X { - pointcut pManual(): withincode(* runOne(..)) && get(@Marker * *); - pointcut pWoven(Marker l): withincode(* runTwo(..)) && get(@Marker * * ) && @annotation(l); + pointcut pReflective(): withincode(* runOne(..)) && get(@Marker * *); + pointcut pBound(Marker marker): withincode(* runTwo(..)) && get(@Marker * * ) && @annotation(marker); - public static int a,b; + public static int sumReflective, sumBound; - before(): pManual() { - Marker marker = (Marker) ((FieldSignature) thisJoinPointStaticPart.getSignature()).getField().getAnnotation(Marker.class); - String s = marker.message(); - a+=s.length(); - } - - before(Marker l): pWoven(l) { - String s = l.message(); - b+=s.length(); - } + before(): pReflective() { + Marker marker = (Marker) ((FieldSignature) thisJoinPointStaticPart.getSignature()).getField().getAnnotation(Marker.class); + sumReflective += marker.message().length(); + } + before(Marker marker): pBound(marker) { + sumBound += marker.message().length(); + } } |