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.18 by jsr166, Fri Jan 6 15:53:18 2017 UTC vs.
Revision 1.19 by jsr166, Sat Apr 15 02:06:03 2017 UTC

# Line 56 | Line 56 | import java.util.concurrent.ConcurrentSk
56   import java.util.concurrent.CountDownLatch;
57   import java.util.concurrent.ThreadLocalRandom;
58   import java.util.concurrent.TimeUnit;
59 + import java.util.concurrent.atomic.LongAdder;
60   import java.util.regex.Pattern;
61  
62   /**
# Line 391 | Line 392 | public class IteratorMicroBenchmark {
392                          for (Integer o : x.toArray(empty))
393                              sum[0] += o;
394                          check.sum(sum[0]);}}},
395 +            new Job(klazz + " stream().forEach") {
396 +                public void work() throws Throwable {
397 +                    int[] sum = new int[1];
398 +                    for (int i = 0; i < iterations; i++) {
399 +                        sum[0] = 0;
400 +                        x.stream().forEach(n -> sum[0] += n);
401 +                        check.sum(sum[0]);}}},
402 +            new Job(klazz + " stream().mapToInt") {
403 +                public void work() throws Throwable {
404 +                    for (int i = 0; i < iterations; i++) {
405 +                        check.sum(x.stream().mapToInt(e -> e).sum());}}},
406              new Job(klazz + " stream().collect") {
407                  public void work() throws Throwable {
408                      for (int i = 0; i < iterations; i++) {
409                          check.sum(x.stream()
410                                    .collect(summingInt(e -> e)));}}},
411 +            new Job(klazz + " parallelStream().forEach") {
412 +                public void work() throws Throwable {
413 +                    for (int i = 0; i < iterations; i++) {
414 +                        LongAdder sum = new LongAdder();
415 +                        x.parallelStream().forEach(n -> sum.add(n));
416 +                        check.sum((int) sum.sum());}}},
417 +            new Job(klazz + " parallelStream().mapToInt") {
418 +                public void work() throws Throwable {
419 +                    for (int i = 0; i < iterations; i++) {
420 +                        check.sum(x.parallelStream().mapToInt(e -> e).sum());}}},
421              new Job(klazz + " parallelStream().collect") {
422                  public void work() throws Throwable {
423                      for (int i = 0; i < iterations; i++) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines