Upgrade to latest (at the time of writing) version of Caliper

This does not upgrade to a released version of Caliper, it's
just a snapshot, see README.android for details.

Since 0.5-rc1 Caliper has gone through a huge number of changes
but it still does essentially the same job in the same way it
is just more flexible and capable than the previous version.

One major change that impacts the build is that this version
uses the Dagger2 dependency injection framework that generates
some of its code using annotation processors and so it was
necessary to change the build to use Dagger2.

Not all the Caliper tests run on Android, some are written for
the JVM and rely on some characteristic of it that is not the
same on Android, whether it be available memory, exception
message, supported classes or file structure. There are also a
couple of failures that are not completely explainable at the
moment. The details of these failures are listed in the
expectations/knownfailures.txt and will be addressed at a later
date.

Bug: 24848946
Change-Id: Ia245db56c57315ce18db8eb219003fecf3c64ab9
diff --git a/examples/src/main/java/examples/ListIterationBenchmark.java b/examples/src/main/java/examples/ListIterationBenchmark.java
index a8cfb05..07ae8eb 100644
--- a/examples/src/main/java/examples/ListIterationBenchmark.java
+++ b/examples/src/main/java/examples/ListIterationBenchmark.java
@@ -16,16 +16,17 @@
 
 package examples;
 
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Benchmark;
 import com.google.caliper.Param;
-import com.google.caliper.Runner;
-import com.google.caliper.SimpleBenchmark;
+
 import java.util.AbstractList;
 import java.util.List;
 
 /**
  * Measures iterating through list elements.
  */
-public class ListIterationBenchmark extends SimpleBenchmark {
+public class ListIterationBenchmark {
 
   @Param({"0", "10", "100", "1000"})
   private int length;
@@ -33,7 +34,7 @@
   private List<Object> list;
   private Object[] array;
 
-  @Override protected void setUp() {
+  @BeforeExperiment void setUp() {
     array = new Object[length];
     for (int i = 0; i < length; i++) {
       array[i] = new Object();
@@ -50,24 +51,23 @@
     };
   }
 
-  @SuppressWarnings({"UnusedDeclaration"}) // TODO: fix
-  public void timeListIteration(int reps) {
+  @Benchmark int listIteration(int reps) {
+    int dummy = 0;
     for (int i = 0; i < reps; i++) {
       for (Object value : list) {
+        dummy |= value.hashCode();
       }
     }
+    return dummy;
   }
 
-  @SuppressWarnings({"UnusedDeclaration"}) // TODO: fix
-  public void timeArrayIteration(int reps) {
+  @Benchmark int arrayIteration(int reps) {
+    int dummy = 0;
     for (int i = 0; i < reps; i++) {
       for (Object value : array) {
+        dummy |= value.hashCode();
       }
     }
-  }
-
-  // TODO: remove this from all examples when IDE plugins are ready
-  public static void main(String[] args) throws Exception {
-    Runner.main(ListIterationBenchmark.class, args);
+    return dummy;
   }
 }
\ No newline at end of file