56 |
|
import java.util.concurrent.ThreadLocalRandom; |
57 |
|
import java.util.concurrent.TimeUnit; |
58 |
|
import java.util.concurrent.atomic.LongAdder; |
59 |
+ |
import java.util.function.UnaryOperator; |
60 |
|
import java.util.regex.Pattern; |
61 |
|
import java.util.stream.Stream; |
62 |
|
|
537 |
|
sum[0] = 0; |
538 |
|
if (x.lastIndexOf(sneakyAdder) != -1) |
539 |
|
throw new AssertionError(); |
540 |
+ |
check.sum(sum[0]);}}}, |
541 |
+ |
new Job(klazz + " replaceAll") { |
542 |
+ |
public void work() throws Throwable { |
543 |
+ |
int[] sum = new int[1]; |
544 |
+ |
UnaryOperator<Integer> sneakyAdder = |
545 |
+ |
x -> { sum[0] += x; return x; }; |
546 |
+ |
for (int i = 0; i < iterations; i++) { |
547 |
+ |
sum[0] = 0; |
548 |
+ |
x.replaceAll(sneakyAdder); |
549 |
|
check.sum(sum[0]);}}}); |
550 |
|
} |
551 |
|
} |