Adds benchmarks for ArrayList

Change-Id: I5c1fcd2ac65fdd88552dcd9f35a8afe7867e3a46
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectAddBenchmark.gwt.xml b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectAddBenchmark.gwt.xml
new file mode 100644
index 0000000..a97bdaf
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectAddBenchmark.gwt.xml
@@ -0,0 +1,19 @@
+<!--                                                                        -->
+<!-- Copyright 2015 Google Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you    -->
+<!-- may not use this file except in compliance with the License. You may   -->
+<!-- may obtain a copy of the License at                                    -->
+<!--                                                                        -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                        -->
+<!-- Unless required by applicable law or agreed to in writing, software    -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        -->
+<!-- implied. License for the specific language governing permissions and   -->
+<!-- limitations under the License.                                         -->
+
+<module>
+  <inherits name="com.google.gwt.benchmark.benchmarks.java.util.Util"/>
+  <source path="shared" includes="ArrayListObjectAddBenchmark.java"/>
+  <entry-point class="com.google.gwt.benchmark.benchmarks.java.util.shared.ArrayListObjectAddBenchmark.EntryPoint"/>
+</module>
\ No newline at end of file
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectGetBenchmark.gwt.xml b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectGetBenchmark.gwt.xml
new file mode 100644
index 0000000..a4e8584
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectGetBenchmark.gwt.xml
@@ -0,0 +1,19 @@
+<!--                                                                        -->
+<!-- Copyright 2015 Google Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you    -->
+<!-- may not use this file except in compliance with the License. You may   -->
+<!-- may obtain a copy of the License at                                    -->
+<!--                                                                        -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                        -->
+<!-- Unless required by applicable law or agreed to in writing, software    -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        -->
+<!-- implied. License for the specific language governing permissions and   -->
+<!-- limitations under the License.                                         -->
+
+<module>
+  <inherits name="com.google.gwt.benchmark.benchmarks.java.util.Util"/>
+  <source path="shared" includes="ArrayListObjectGetBenchmark.java"/>
+  <entry-point class="com.google.gwt.benchmark.benchmarks.java.util.shared.ArrayListObjectGetBenchmark.EntryPoint"/>
+</module>
\ No newline at end of file
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectIterationBenchmark.gwt.xml b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectIterationBenchmark.gwt.xml
new file mode 100644
index 0000000..0a5b59e
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectIterationBenchmark.gwt.xml
@@ -0,0 +1,19 @@
+<!--                                                                        -->
+<!-- Copyright 2015 Google Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you    -->
+<!-- may not use this file except in compliance with the License. You may   -->
+<!-- may obtain a copy of the License at                                    -->
+<!--                                                                        -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                        -->
+<!-- Unless required by applicable law or agreed to in writing, software    -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        -->
+<!-- implied. License for the specific language governing permissions and   -->
+<!-- limitations under the License.                                         -->
+
+<module>
+  <inherits name="com.google.gwt.benchmark.benchmarks.java.util.Util"/>
+  <source path="shared" includes="ArrayListObjectIterationBenchmark.java"/>
+  <entry-point class="com.google.gwt.benchmark.benchmarks.java.util.shared.ArrayListObjectIterationBenchmark.EntryPoint"/>
+</module>
\ No newline at end of file
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectSetBenchmark.gwt.xml b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectSetBenchmark.gwt.xml
new file mode 100644
index 0000000..f222430
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/ArrayListObjectSetBenchmark.gwt.xml
@@ -0,0 +1,19 @@
+<!--                                                                        -->
+<!-- Copyright 2015 Google Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you    -->
+<!-- may not use this file except in compliance with the License. You may   -->
+<!-- may obtain a copy of the License at                                    -->
+<!--                                                                        -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                        -->
+<!-- Unless required by applicable law or agreed to in writing, software    -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        -->
+<!-- implied. License for the specific language governing permissions and   -->
+<!-- limitations under the License.                                         -->
+
+<module>
+  <inherits name="com.google.gwt.benchmark.benchmarks.java.util.Util"/>
+  <source path="shared" includes="ArrayListObjectSetBenchmark.java"/>
+  <entry-point class="com.google.gwt.benchmark.benchmarks.java.util.shared.ArrayListObjectSetBenchmark.EntryPoint"/>
+</module>
\ No newline at end of file
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectAddBenchmark.java b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectAddBenchmark.java
new file mode 100644
index 0000000..5e6a258
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectAddBenchmark.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.benchmark.benchmarks.java.util.shared;
+
+import com.google.gwt.benchmark.framework.client.AbstractBenchmarkEntryPoint;
+import com.google.gwt.benchmark.framework.shared.AbstractBenchmark;
+
+import java.util.ArrayList;
+
+/**
+ * Benchmark array set performance.
+ */
+public class ArrayListObjectAddBenchmark extends AbstractBenchmark {
+
+  public static class EntryPoint extends AbstractBenchmarkEntryPoint {
+    @Override
+    protected AbstractBenchmark getBenchmark() {
+      return new ArrayListObjectAddBenchmark();
+    }
+  }
+
+  private ArrayList<Object> arrayList;
+  private Object testObjectInstance = "test";
+
+  public ArrayListObjectAddBenchmark() {
+    super("ArrayTestObjectGetBenchmark");
+  }
+
+  @Override
+  public Object run() {
+    for (int i = 0; i < 1000; i++) {
+      arrayList.add(testObjectInstance);
+    }
+
+    return arrayList;
+  }
+
+  @Override
+  public void setup() {
+    arrayList = new ArrayList<Object>();
+  }
+}
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectGetBenchmark.java b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectGetBenchmark.java
new file mode 100644
index 0000000..4eca945
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectGetBenchmark.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.benchmark.benchmarks.java.util.shared;
+
+import com.google.gwt.benchmark.framework.client.AbstractBenchmarkEntryPoint;
+import com.google.gwt.benchmark.framework.shared.AbstractBenchmark;
+
+import java.util.ArrayList;
+
+/**
+ * Benchmark ArrayList get performance.
+ */
+public class ArrayListObjectGetBenchmark extends AbstractBenchmark {
+
+  public static class EntryPoint extends AbstractBenchmarkEntryPoint {
+    @Override
+    protected AbstractBenchmark getBenchmark() {
+      return new ArrayListObjectGetBenchmark();
+    }
+  }
+
+  private ArrayList<Object> arrayList;
+
+  public ArrayListObjectGetBenchmark() {
+    super("ArrayListObjectGetBenchmark");
+  }
+
+  @Override
+  public Object run() {
+    int sum = 0;
+
+    for (int i = 0; i < 1000; i++) {
+      Object object = arrayList.get(i);
+      if (object != null) {
+        sum++;
+      }
+    }
+
+    // compare value - disables opts and finds JIT bugs
+    if (sum != 1000) {
+      throw new RuntimeException();
+    }
+
+    return Integer.valueOf(sum);
+  }
+
+  @Override
+  public void setupOneTime() {
+    arrayList = new ArrayList<Object>();
+    for (int i = 0; i < 1000; i++) {
+      arrayList.add(":" + i);
+    }
+  }
+}
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectIterationBenchmark.java b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectIterationBenchmark.java
new file mode 100644
index 0000000..6fd1309
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectIterationBenchmark.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.benchmark.benchmarks.java.util.shared;
+
+import com.google.gwt.benchmark.framework.client.AbstractBenchmarkEntryPoint;
+import com.google.gwt.benchmark.framework.shared.AbstractBenchmark;
+
+import java.util.ArrayList;
+
+/**
+ * Benchmark ArrayList iteration performance.
+ */
+public class ArrayListObjectIterationBenchmark extends AbstractBenchmark {
+
+  public static class EntryPoint extends AbstractBenchmarkEntryPoint {
+    @Override
+    protected AbstractBenchmark getBenchmark() {
+      return new ArrayListObjectIterationBenchmark();
+    }
+  }
+
+  private ArrayList<Object> arrayList;
+
+  public ArrayListObjectIterationBenchmark() {
+    super("ArrayListObjectIterationBenchmark");
+  }
+
+  @Override
+  public Object run() {
+    int sum = 0;
+
+    for (Object object : arrayList) {
+      if (object != null) {
+        sum++;
+      }
+    }
+
+    // compare value - disables opts and finds JIT bugs
+    if (sum != 1000) {
+      throw new RuntimeException();
+    }
+
+    return Integer.valueOf(sum);
+  }
+
+  @Override
+  public void setupOneTime() {
+    arrayList = new ArrayList<Object>();
+    for (int i = 0; i < 1000; i++) {
+      arrayList.add(":" + i);
+    }
+  }
+}
diff --git a/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectSetBenchmark.java b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectSetBenchmark.java
new file mode 100644
index 0000000..d74017b
--- /dev/null
+++ b/benchmarks/src/main/java/com/google/gwt/benchmark/benchmarks/java/util/shared/ArrayListObjectSetBenchmark.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.benchmark.benchmarks.java.util.shared;
+
+import com.google.gwt.benchmark.framework.client.AbstractBenchmarkEntryPoint;
+import com.google.gwt.benchmark.framework.shared.AbstractBenchmark;
+
+import java.util.ArrayList;
+
+/**
+ * Benchmark ArrayList set performance.
+ */
+public class ArrayListObjectSetBenchmark extends AbstractBenchmark {
+
+  public static class EntryPoint extends AbstractBenchmarkEntryPoint {
+    @Override
+    protected AbstractBenchmark getBenchmark() {
+      return new ArrayListObjectSetBenchmark();
+    }
+  }
+
+  private ArrayList<Object> arrayList;
+  private Object testObjectInstance = "test";
+
+  public ArrayListObjectSetBenchmark() {
+    super("ArrayListObjectSetBenchmark");
+  }
+
+  @Override
+  public Object run() {
+    for (int i = 0; i < 1000; i++) {
+      arrayList.set(i, testObjectInstance);
+    }
+
+    return arrayList;
+  }
+
+  @Override
+  public void setupOneTime() {
+    arrayList = new ArrayList<Object>(1000);
+    for (int i = 0; i < 1000; i++) {
+      arrayList.add("");
+    }
+  }
+}