jdk/test/java/util/Collection/RemoveMicroBenchmark.java
author dl
Fri, 03 Feb 2017 13:24:59 -0800
changeset 43521 60e247b8d9a4
parent 42319 0193886267c3
permissions -rw-r--r--
8169748: LinkedTransferQueue bulk remove is O(n^2) 8172023: Concurrent spliterators fail to handle exhaustion properly Reviewed-by: martin, psandoz, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42319
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     1
/*
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     2
 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     4
 *
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     8
 *
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    13
 * accompanied this code).
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    14
 *
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    18
 *
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    21
 * questions.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    22
 */
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    23
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    24
/*
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    25
 * @test
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    26
 * @summary micro-benchmark correctness mode
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    27
 * @run main RemoveMicroBenchmark iterations=1 size=8 warmup=0
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    28
 */
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    29
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    30
import java.lang.ref.WeakReference;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    31
import java.util.ArrayDeque;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    32
import java.util.Arrays;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    33
import java.util.ArrayList;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    34
import java.util.Collection;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    35
import java.util.Collections;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    36
import java.util.Deque;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    37
import java.util.Enumeration;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    38
import java.util.Iterator;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    39
import java.util.LinkedList;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    40
import java.util.List;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    41
import java.util.ListIterator;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    42
import java.util.Map;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    43
import java.util.PriorityQueue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    44
import java.util.Queue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    45
import java.util.Spliterator;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    46
import java.util.Vector;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    47
import java.util.concurrent.ArrayBlockingQueue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    48
import java.util.concurrent.BlockingDeque;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    49
import java.util.concurrent.BlockingQueue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    50
import java.util.concurrent.ConcurrentLinkedDeque;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    51
import java.util.concurrent.ConcurrentLinkedQueue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    52
import java.util.concurrent.CountDownLatch;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    53
import java.util.concurrent.LinkedBlockingDeque;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    54
import java.util.concurrent.LinkedBlockingQueue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    55
import java.util.concurrent.LinkedTransferQueue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    56
import java.util.concurrent.PriorityBlockingQueue;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    57
import java.util.concurrent.ThreadLocalRandom;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    58
import java.util.concurrent.TimeUnit;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    59
import java.util.regex.Pattern;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    60
import java.util.function.Supplier;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    61
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    62
/**
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    63
 * Usage: [iterations=N] [size=N] [filter=REGEXP] [warmup=SECONDS]
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    64
 *
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    65
 * To run this in micro-benchmark mode, simply run as a normal java program.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    66
 * Be patient; this program runs for a very long time.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    67
 * For faster runs, restrict execution using command line args.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    68
 *
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    69
 * @author Martin Buchholz
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    70
 */
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    71
public class RemoveMicroBenchmark {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    72
    abstract static class Job {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    73
        private final String name;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    74
        public Job(String name) { this.name = name; }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    75
        public String name() { return name; }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    76
        public abstract void work() throws Throwable;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    77
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    78
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    79
    final int iterations;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    80
    final int size;             // number of elements in collections
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    81
    final double warmupSeconds;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    82
    final long warmupNanos;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    83
    final Pattern filter;       // select subset of Jobs to run
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    84
    final boolean reverse;      // reverse order of Jobs
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    85
    final boolean shuffle;      // randomize order of Jobs
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    86
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    87
    RemoveMicroBenchmark(String[] args) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    88
        iterations    = intArg(args, "iterations", 10_000);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    89
        size          = intArg(args, "size", 1000);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    90
        warmupSeconds = doubleArg(args, "warmup", 7.0);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    91
        filter        = patternArg(args, "filter");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    92
        reverse       = booleanArg(args, "reverse");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    93
        shuffle       = booleanArg(args, "shuffle");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    94
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    95
        warmupNanos = (long) (warmupSeconds * (1000L * 1000L * 1000L));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    96
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    97
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    98
    // --------------- GC finalization infrastructure ---------------
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
    99
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   100
    /** No guarantees, but effective in practice. */
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   101
    static void forceFullGc() {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   102
        CountDownLatch finalizeDone = new CountDownLatch(1);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   103
        WeakReference<?> ref = new WeakReference<Object>(new Object() {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   104
            protected void finalize() { finalizeDone.countDown(); }});
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   105
        try {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   106
            for (int i = 0; i < 10; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   107
                System.gc();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   108
                if (finalizeDone.await(1L, TimeUnit.SECONDS) && ref.get() == null) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   109
                    System.runFinalization(); // try to pick up stragglers
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   110
                    return;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   111
                }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   112
            }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   113
        } catch (InterruptedException unexpected) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   114
            throw new AssertionError("unexpected InterruptedException");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   115
        }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   116
        throw new AssertionError("failed to do a \"full\" gc");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   117
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   118
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   119
    /**
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   120
     * Runs each job for long enough that all the runtime compilers
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   121
     * have had plenty of time to warm up, i.e. get around to
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   122
     * compiling everything worth compiling.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   123
     * Returns array of average times per job per run.
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   124
     */
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   125
    long[] time0(List<Job> jobs) throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   126
        final int size = jobs.size();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   127
        long[] nanoss = new long[size];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   128
        for (int i = 0; i < size; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   129
            if (warmupNanos > 0) forceFullGc();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   130
            Job job = jobs.get(i);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   131
            long totalTime;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   132
            int runs = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   133
            long startTime = System.nanoTime();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   134
            do { job.work(); runs++; }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   135
            while ((totalTime = System.nanoTime() - startTime) < warmupNanos);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   136
            nanoss[i] = totalTime/runs;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   137
        }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   138
        return nanoss;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   139
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   140
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   141
    void time(List<Job> jobs) throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   142
        if (warmupNanos > 0) time0(jobs); // Warm up run
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   143
        final int size = jobs.size();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   144
        final long[] nanoss = time0(jobs); // Real timing run
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   145
        final long[] milliss = new long[size];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   146
        final double[] ratios = new double[size];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   147
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   148
        final String nameHeader   = "Method";
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   149
        final String millisHeader = "Millis";
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   150
        final String ratioHeader  = "Ratio";
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   151
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   152
        int nameWidth   = nameHeader.length();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   153
        int millisWidth = millisHeader.length();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   154
        int ratioWidth  = ratioHeader.length();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   155
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   156
        for (int i = 0; i < size; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   157
            nameWidth = Math.max(nameWidth, jobs.get(i).name().length());
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   158
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   159
            milliss[i] = nanoss[i]/(1000L * 1000L);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   160
            millisWidth = Math.max(millisWidth,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   161
                                   String.format("%d", milliss[i]).length());
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   162
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   163
            ratios[i] = (double) nanoss[i] / (double) nanoss[0];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   164
            ratioWidth = Math.max(ratioWidth,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   165
                                  String.format("%.3f", ratios[i]).length());
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   166
        }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   167
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   168
        String format = String.format("%%-%ds %%%dd %%%d.3f%%n",
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   169
                                      nameWidth, millisWidth, ratioWidth);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   170
        String headerFormat = String.format("%%-%ds %%%ds %%%ds%%n",
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   171
                                            nameWidth, millisWidth, ratioWidth);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   172
        System.out.printf(headerFormat, "Method", "Millis", "Ratio");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   173
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   174
        // Print out absolute and relative times, calibrated against first job
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   175
        for (int i = 0; i < size; i++)
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   176
            System.out.printf(format, jobs.get(i).name(), milliss[i], ratios[i]);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   177
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   178
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   179
    private static String keywordValue(String[] args, String keyword) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   180
        for (String arg : args)
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   181
            if (arg.startsWith(keyword))
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   182
                return arg.substring(keyword.length() + 1);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   183
        return null;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   184
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   185
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   186
    private static int intArg(String[] args, String keyword, int defaultValue) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   187
        String val = keywordValue(args, keyword);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   188
        return (val == null) ? defaultValue : Integer.parseInt(val);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   189
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   190
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   191
    private static double doubleArg(String[] args, String keyword, double defaultValue) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   192
        String val = keywordValue(args, keyword);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   193
        return (val == null) ? defaultValue : Double.parseDouble(val);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   194
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   195
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   196
    private static Pattern patternArg(String[] args, String keyword) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   197
        String val = keywordValue(args, keyword);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   198
        return (val == null) ? null : Pattern.compile(val);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   199
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   200
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   201
    private static boolean booleanArg(String[] args, String keyword) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   202
        String val = keywordValue(args, keyword);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   203
        if (val == null || val.equals("false")) return false;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   204
        if (val.equals("true")) return true;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   205
        throw new IllegalArgumentException(val);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   206
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   207
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   208
    private static List<Job> filter(Pattern filter, List<Job> jobs) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   209
        if (filter == null) return jobs;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   210
        ArrayList<Job> newJobs = new ArrayList<>();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   211
        for (Job job : jobs)
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   212
            if (filter.matcher(job.name()).find())
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   213
                newJobs.add(job);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   214
        return newJobs;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   215
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   216
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   217
    private static void deoptimize(int sum) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   218
        if (sum == 42)
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   219
            System.out.println("the answer");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   220
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   221
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   222
    private static <T> List<T> asSubList(List<T> list) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   223
        return list.subList(0, list.size());
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   224
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   225
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   226
    private static <T> Iterable<T> backwards(final List<T> list) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   227
        return new Iterable<T>() {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   228
            public Iterator<T> iterator() {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   229
                return new Iterator<T>() {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   230
                    final ListIterator<T> it = list.listIterator(list.size());
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   231
                    public boolean hasNext() { return it.hasPrevious(); }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   232
                    public T next()          { return it.previous(); }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   233
                    public void remove()     {        it.remove(); }};}};
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   234
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   235
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   236
    // Checks for correctness *and* prevents loop optimizations
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   237
    class Check {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   238
        private int sum;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   239
        public void sum(int sum) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   240
            if (this.sum == 0)
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   241
                this.sum = sum;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   242
            if (this.sum != sum)
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   243
                throw new AssertionError("Sum mismatch");
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   244
        }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   245
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   246
    volatile Check check = new Check();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   247
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   248
    public static void main(String[] args) throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   249
        new RemoveMicroBenchmark(args).run();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   250
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   251
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   252
    void run() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   253
//         System.out.printf(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   254
//             "iterations=%d size=%d, warmup=%1g, filter=\"%s\"%n",
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   255
//             iterations, size, warmupSeconds, filter);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   256
43521
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   257
        final ArrayList<Integer> al = new ArrayList<>(size);
42319
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   258
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   259
        // Populate collections with random data
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   260
        final ThreadLocalRandom rnd = ThreadLocalRandom.current();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   261
        for (int i = 0; i < size; i++)
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   262
            al.add(rnd.nextInt(size));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   263
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   264
        ArrayList<Job> jobs = new ArrayList<>();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   265
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   266
        List.<Collection<Integer>>of(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   267
            new ArrayList<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   268
            new LinkedList<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   269
            new Vector<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   270
            new ArrayDeque<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   271
            new PriorityQueue<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   272
            new ArrayBlockingQueue<>(al.size()),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   273
            new ConcurrentLinkedQueue<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   274
            new ConcurrentLinkedDeque<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   275
            new LinkedBlockingQueue<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   276
            new LinkedBlockingDeque<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   277
            new LinkedTransferQueue<>(),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   278
            new PriorityBlockingQueue<>())
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   279
            .stream().forEach(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   280
                x -> {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   281
                    String klazz = x.getClass().getSimpleName();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   282
                    jobs.addAll(collectionJobs(klazz, () -> x, al));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   283
                    if (x instanceof Queue) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   284
                        Queue<Integer> queue = (Queue<Integer>) x;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   285
                        jobs.addAll(queueJobs(klazz, () -> queue, al));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   286
                    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   287
                    if (x instanceof Deque) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   288
                        Deque<Integer> deque = (Deque<Integer>) x;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   289
                        jobs.addAll(dequeJobs(klazz, () -> deque, al));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   290
                    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   291
                    if (x instanceof BlockingQueue) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   292
                        BlockingQueue<Integer> q = (BlockingQueue<Integer>) x;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   293
                        jobs.addAll(blockingQueueJobs(klazz, () -> q, al));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   294
                    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   295
                    if (x instanceof BlockingDeque) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   296
                        BlockingDeque<Integer> q = (BlockingDeque<Integer>) x;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   297
                        jobs.addAll(blockingDequeJobs(klazz, () -> q, al));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   298
                    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   299
                    if (x instanceof List) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   300
                        List<Integer> list = (List<Integer>) x;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   301
                        jobs.addAll(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   302
                            collectionJobs(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   303
                                klazz + " subList",
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   304
                                () -> list.subList(0, x.size()),
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   305
                                al));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   306
                    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   307
                });
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   308
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   309
        if (reverse) Collections.reverse(jobs);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   310
        if (shuffle) Collections.shuffle(jobs);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   311
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   312
        time(filter(filter, jobs));
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   313
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   314
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   315
    Collection<Integer> universeRecorder(int[] sum) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   316
        return new ArrayList<>() {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   317
            public boolean contains(Object x) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   318
                sum[0] += (Integer) x;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   319
                return true;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   320
            }};
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   321
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   322
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   323
    Collection<Integer> emptyRecorder(int[] sum) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   324
        return new ArrayList<>() {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   325
            public boolean contains(Object x) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   326
                sum[0] += (Integer) x;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   327
                return false;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   328
            }};
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   329
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   330
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   331
    List<Job> collectionJobs(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   332
        String description,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   333
        Supplier<Collection<Integer>> supplier,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   334
        ArrayList<Integer> al) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   335
        return List.of(
43521
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   336
            new Job(description + " removeIf") {
42319
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   337
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   338
                    Collection<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   339
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   340
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   341
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   342
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   343
                        x.removeIf(n -> { sum[0] += n; return true; });
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   344
                        check.sum(sum[0]);}}},
43521
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   345
            new Job(description + " removeIf rnd-two-pass") {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   346
                public void work() throws Throwable {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   347
                    ThreadLocalRandom rnd = ThreadLocalRandom.current();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   348
                    Collection<Integer> x = supplier.get();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   349
                    int[] sum = new int[1];
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   350
                    for (int i = 0; i < iterations; i++) {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   351
                        sum[0] = 0;
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   352
                        x.addAll(al);
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   353
                        x.removeIf(n -> {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   354
                            boolean b = rnd.nextBoolean();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   355
                            if (b) sum[0] += n;
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   356
                            return b; });
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   357
                        x.removeIf(n -> { sum[0] += n; return true; });
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   358
                        check.sum(sum[0]);}}},
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   359
            new Job(description + " removeAll") {
42319
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   360
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   361
                    Collection<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   362
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   363
                    Collection<Integer> universe = universeRecorder(sum);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   364
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   365
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   366
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   367
                        x.removeAll(universe);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   368
                        check.sum(sum[0]);}}},
43521
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   369
            new Job(description + " retainAll") {
42319
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   370
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   371
                    Collection<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   372
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   373
                    Collection<Integer> empty = emptyRecorder(sum);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   374
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   375
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   376
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   377
                        x.retainAll(empty);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   378
                        check.sum(sum[0]);}}},
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   379
            new Job(description + " Iterator.remove") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   380
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   381
                    Collection<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   382
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   383
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   384
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   385
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   386
                        Iterator<Integer> it = x.iterator();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   387
                        while (it.hasNext()) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   388
                            sum[0] += it.next();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   389
                            it.remove();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   390
                        }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   391
                        check.sum(sum[0]);}}},
43521
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   392
            new Job(description + " Iterator.remove-rnd-two-pass") {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   393
                public void work() throws Throwable {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   394
                    ThreadLocalRandom rnd = ThreadLocalRandom.current();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   395
                    Collection<Integer> x = supplier.get();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   396
                    int[] sum = new int[1];
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   397
                    for (int i = 0; i < iterations; i++) {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   398
                        sum[0] = 0;
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   399
                        x.addAll(al);
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   400
                        for (Iterator<Integer> it = x.iterator();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   401
                             it.hasNext(); ) {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   402
                            Integer e = it.next();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   403
                            if (rnd.nextBoolean()) {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   404
                                sum[0] += e;
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   405
                                it.remove();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   406
                            }
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   407
                        }
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   408
                        for (Iterator<Integer> it = x.iterator();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   409
                             it.hasNext(); ) {
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   410
                            sum[0] += it.next();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   411
                            it.remove();
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   412
                        }
60e247b8d9a4 8169748: LinkedTransferQueue bulk remove is O(n^2)
dl
parents: 42319
diff changeset
   413
                        check.sum(sum[0]);}}},
42319
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   414
            new Job(description + " clear") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   415
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   416
                    Collection<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   417
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   418
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   419
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   420
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   421
                        x.forEach(e -> sum[0] += e);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   422
                        x.clear();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   423
                        check.sum(sum[0]);}}});
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   424
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   425
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   426
    List<Job> queueJobs(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   427
        String description,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   428
        Supplier<Queue<Integer>> supplier,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   429
        ArrayList<Integer> al) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   430
        return List.of(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   431
            new Job(description + " poll()") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   432
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   433
                    Queue<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   434
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   435
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   436
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   437
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   438
                        for (Integer e; (e = x.poll()) != null; )
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   439
                            sum[0] += e;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   440
                        check.sum(sum[0]);}}});
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   441
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   442
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   443
    List<Job> dequeJobs(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   444
        String description,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   445
        Supplier<Deque<Integer>> supplier,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   446
        ArrayList<Integer> al) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   447
        return List.of(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   448
            new Job(description + " descendingIterator().remove") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   449
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   450
                    Deque<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   451
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   452
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   453
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   454
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   455
                        Iterator<Integer> it = x.descendingIterator();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   456
                        while (it.hasNext()) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   457
                            sum[0] += it.next();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   458
                            it.remove();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   459
                        }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   460
                        check.sum(sum[0]);}}},
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   461
            new Job(description + " pollFirst()") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   462
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   463
                    Deque<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   464
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   465
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   466
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   467
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   468
                        for (Integer e; (e = x.pollFirst()) != null; )
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   469
                            sum[0] += e;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   470
                        check.sum(sum[0]);}}},
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   471
            new Job(description + " pollLast()") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   472
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   473
                    Deque<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   474
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   475
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   476
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   477
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   478
                        for (Integer e; (e = x.pollLast()) != null; )
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   479
                            sum[0] += e;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   480
                        check.sum(sum[0]);}}});
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   481
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   482
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   483
    List<Job> blockingQueueJobs(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   484
        String description,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   485
        Supplier<BlockingQueue<Integer>> supplier,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   486
        ArrayList<Integer> al) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   487
        return List.of(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   488
            new Job(description + " drainTo(sink)") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   489
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   490
                    BlockingQueue<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   491
                    ArrayList<Integer> sink = new ArrayList<>();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   492
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   493
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   494
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   495
                        sink.clear();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   496
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   497
                        x.drainTo(sink);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   498
                        sink.forEach(e -> sum[0] += e);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   499
                        check.sum(sum[0]);}}},
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   500
            new Job(description + " drainTo(sink, n)") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   501
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   502
                    BlockingQueue<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   503
                    ArrayList<Integer> sink = new ArrayList<>();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   504
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   505
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   506
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   507
                        sink.clear();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   508
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   509
                        x.drainTo(sink, al.size());
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   510
                        sink.forEach(e -> sum[0] += e);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   511
                        check.sum(sum[0]);}}});
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   512
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   513
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   514
    List<Job> blockingDequeJobs(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   515
        String description,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   516
        Supplier<BlockingDeque<Integer>> supplier,
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   517
        ArrayList<Integer> al) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   518
        return List.of(
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   519
            new Job(description + " timed pollFirst()") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   520
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   521
                    BlockingDeque<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   522
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   523
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   524
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   525
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   526
                        for (Integer e; (e = x.pollFirst(0L, TimeUnit.DAYS)) != null; )
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   527
                            sum[0] += e;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   528
                        check.sum(sum[0]);}}},
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   529
            new Job(description + " timed pollLast()") {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   530
                public void work() throws Throwable {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   531
                    BlockingDeque<Integer> x = supplier.get();
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   532
                    int[] sum = new int[1];
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   533
                    for (int i = 0; i < iterations; i++) {
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   534
                        sum[0] = 0;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   535
                        x.addAll(al);
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   536
                        for (Integer e; (e = x.pollLast(0L, TimeUnit.DAYS)) != null; )
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   537
                            sum[0] += e;
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   538
                        check.sum(sum[0]);}}});
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   539
    }
0193886267c3 8143577: optimize ArrayList.removeIf
dl
parents:
diff changeset
   540
}