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.34 by jsr166, Sun Jan 28 07:02:19 2018 UTC vs.
Revision 1.35 by jsr166, Sun Mar 25 13:59:05 2018 UTC

# Line 466 | Line 466 | public class IteratorMicroBenchmark {
466      }
467  
468      Stream<Job> listJobs(List<Integer> x) {
469 <        String klazz = x.getClass().getSimpleName();
469 >        final String klazz = x.getClass().getSimpleName();
470          return Stream.of(
471              new Job(klazz + " subList toArray()") {
472                  public void work() throws Throwable {
# Line 508 | Line 508 | public class IteratorMicroBenchmark {
508                                      sum += (Integer) o;
509                                  return sum; })
510                              .sum();
511 <                        check.sum(total);}}});
511 >                        check.sum(total);}}},
512 >            new Job(klazz + " indexOf") {
513 >                public void work() throws Throwable {
514 >                    int[] sum = new int[1];
515 >                    Object y = new Object() {
516 >                        public boolean equals(Object z) {
517 >                            sum[0] += (int) z; return false; }};
518 >                    for (int i = 0; i < iterations; i++) {
519 >                        sum[0] = 0;
520 >                        if (x.indexOf(y) != -1) throw new AssertionError();
521 >                        check.sum(sum[0]);}}},
522 >            new Job(klazz + " lastIndexOf") {
523 >                public void work() throws Throwable {
524 >                    int[] sum = new int[1];
525 >                    Object y = new Object() {
526 >                        public boolean equals(Object z) {
527 >                            sum[0] += (int) z; return false; }};
528 >                    for (int i = 0; i < iterations; i++) {
529 >                        sum[0] = 0;
530 >                        if (x.lastIndexOf(y) != -1) throw new AssertionError();
531 >                        check.sum(sum[0]);}}});
532      }
533   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines