ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Collection/IteratorMicroBenchmark.java
(Generate patch)

Comparing jsr166/src/test/jtreg/util/Collection/IteratorMicroBenchmark.java (file contents):
Revision 1.38 by jsr166, Mon Mar 26 20:33:27 2018 UTC vs.
Revision 1.39 by jsr166, Mon Mar 26 21:04:36 2018 UTC

# Line 503 | Line 503 | public class IteratorMicroBenchmark {
503                          check.sum(sum[0]);}}});
504      }
505  
506    <T> Job iterateJob(String name, T x, ToIntFunction<T> sumFunction) {
507        return new Job(name) {
508            public void work() throws Throwable {
509                for (int i = 0; i < iterations; i++) {
510                    check.sum(sumFunction.applyAsInt(x));}}};
511    }
512
506      Stream<Job> listJobs(List<Integer> x) {
507          final String klazz = goodClassName(x.getClass());
515        final int[] sneakySum = new int[1];
516        final Object sneakyAdder = sneakyAdder(sneakySum);
517
508          return Stream.of(
509 <            iterateJob(
510 <                klazz + " indexOf", x,
511 <                z -> {
512 <                    sneakySum[0] = 0;
513 <                    if (z.indexOf(sneakyAdder) != -1) throw new AssertionError();
514 <                    return sneakySum[0]; }),
515 <            iterateJob(
516 <                klazz + " lastIndexOf", x,
517 <                z -> {
518 <                    sneakySum[0] = 0;
519 <                    if (z.lastIndexOf(sneakyAdder) != -1) throw new AssertionError();
520 <                    return sneakySum[0]; }));
509 >            new Job(klazz + " indexOf") {
510 >                public void work() throws Throwable {
511 >                    int[] sum = new int[1];
512 >                    Object sneakyAdder = sneakyAdder(sum);
513 >                    for (int i = 0; i < iterations; i++) {
514 >                        sum[0] = 0;
515 >                        if (x.indexOf(sneakyAdder) != -1)
516 >                            throw new AssertionError();
517 >                        check.sum(sum[0]);}}},
518 >            new Job(klazz + " lastIndexOf") {
519 >                public void work() throws Throwable {
520 >                    int[] sum = new int[1];
521 >                    Object sneakyAdder = sneakyAdder(sum);
522 >                    for (int i = 0; i < iterations; i++) {
523 >                        sum[0] = 0;
524 >                        if (x.lastIndexOf(sneakyAdder) != -1)
525 >                            throw new AssertionError();
526 >                        check.sum(sum[0]);}}});
527      }
528   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines