summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2015-12-01 15:41:36 +0000
committer Paul Duffin <paulduffin@google.com> 2015-12-07 12:29:45 +0000
commit76a6cec97f48435863b6ab360e11f5da26d7956b (patch)
tree745aa7fd217b329239b998894dbbfb2d3dd67fad
parent9f6a2ae67c70085d550962829e6bfe76706907d8 (diff)
Switch to the latest version of Caliper
Added an Android.mk file to core/tests/benchmarks to build the benchmarks against caliper-api-target to ensure that they build correctly. Changed the implementations to work with the new version of Caliper. Bug: 24848946 Change-Id: Ib28026816dbc5c1d54f65974f4a1abfee299c43f
-rw-r--r--core/tests/benchmarks/Android.mk32
-rw-r--r--core/tests/benchmarks/src/android/net/NetworkStatsBenchmark.java8
-rw-r--r--core/tests/benchmarks/src/android/net/TrafficStatsBenchmark.java4
-rw-r--r--core/tests/benchmarks/src/android/os/ParcelArrayBenchmark.java10
-rw-r--r--core/tests/benchmarks/src/android/os/ParcelBenchmark.java9
-rw-r--r--core/tests/benchmarks/src/android/os/StrictModeBenchmark.java4
-rw-r--r--core/tests/benchmarks/src/android/util/FloatMathBenchmark.java7
-rw-r--r--core/tests/benchmarks/src/com/android/internal/net/NetworkStatsFactoryBenchmark.java21
-rw-r--r--core/tests/benchmarks/src/com/android/internal/util/IndentingPrintWriterBenchmark.java10
9 files changed, 66 insertions, 39 deletions
diff --git a/core/tests/benchmarks/Android.mk b/core/tests/benchmarks/Android.mk
new file mode 100644
index 000000000000..b7b295aeca99
--- /dev/null
+++ b/core/tests/benchmarks/Android.mk
@@ -0,0 +1,32 @@
+# -*- mode: makefile -*-
+# Copyright (C) 2015 The Android Open Source Project
+#
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+# build framework base core benchmarks
+# ============================================================
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := frameworks-base-core-benchmarks
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_SRC_FILES := $(call all-java-files-under, src/)
+LOCAL_NO_STANDARD_LIBRARIES := true
+
+LOCAL_JAVA_LIBRARIES := \
+ caliper-api-target \
+ framework
+
+include $(BUILD_JAVA_LIBRARY)
diff --git a/core/tests/benchmarks/src/android/net/NetworkStatsBenchmark.java b/core/tests/benchmarks/src/android/net/NetworkStatsBenchmark.java
index 1a5043254e09..1b6560322a13 100644
--- a/core/tests/benchmarks/src/android/net/NetworkStatsBenchmark.java
+++ b/core/tests/benchmarks/src/android/net/NetworkStatsBenchmark.java
@@ -16,10 +16,10 @@
package android.net;
+import com.google.caliper.BeforeExperiment;
import com.google.caliper.Param;
-import com.google.caliper.SimpleBenchmark;
-public class NetworkStatsBenchmark extends SimpleBenchmark {
+public class NetworkStatsBenchmark {
private static final String UNDERLYING_IFACE = "wlan0";
private static final String TUN_IFACE = "tun0";
private static final int TUN_UID = 999999999;
@@ -28,10 +28,8 @@ public class NetworkStatsBenchmark extends SimpleBenchmark {
private int mSize;
private NetworkStats mNetworkStats;
- @Override
+ @BeforeExperiment
protected void setUp() throws Exception {
- super.setUp();
-
mNetworkStats = new NetworkStats(0, mSize + 2);
int uid = 0;
NetworkStats.Entry recycle = new NetworkStats.Entry();
diff --git a/core/tests/benchmarks/src/android/net/TrafficStatsBenchmark.java b/core/tests/benchmarks/src/android/net/TrafficStatsBenchmark.java
index 5a29adc9b000..09de412b5560 100644
--- a/core/tests/benchmarks/src/android/net/TrafficStatsBenchmark.java
+++ b/core/tests/benchmarks/src/android/net/TrafficStatsBenchmark.java
@@ -16,9 +16,7 @@
package android.net;
-import com.google.caliper.SimpleBenchmark;
-
-public class TrafficStatsBenchmark extends SimpleBenchmark {
+public class TrafficStatsBenchmark {
public void timeGetUidRxBytes(int reps) {
for (int i = 0; i < reps; i++) {
TrafficStats.getUidRxBytes(android.os.Process.myUid());
diff --git a/core/tests/benchmarks/src/android/os/ParcelArrayBenchmark.java b/core/tests/benchmarks/src/android/os/ParcelArrayBenchmark.java
index 21cfb0988ebd..eff8c8e4abdf 100644
--- a/core/tests/benchmarks/src/android/os/ParcelArrayBenchmark.java
+++ b/core/tests/benchmarks/src/android/os/ParcelArrayBenchmark.java
@@ -16,10 +16,11 @@
package android.os;
+import com.google.caliper.AfterExperiment;
+import com.google.caliper.BeforeExperiment;
import com.google.caliper.Param;
-import com.google.caliper.SimpleBenchmark;
-public class ParcelArrayBenchmark extends SimpleBenchmark {
+public class ParcelArrayBenchmark {
@Param({ "1", "10", "100", "1000" })
private int mSize;
@@ -34,7 +35,7 @@ public class ParcelArrayBenchmark extends SimpleBenchmark {
private Parcel mIntParcel;
private Parcel mLongParcel;
- @Override
+ @BeforeExperiment
protected void setUp() {
mWriteParcel = Parcel.obtain();
@@ -50,7 +51,7 @@ public class ParcelArrayBenchmark extends SimpleBenchmark {
mLongParcel.writeLongArray(mLongArray);
}
- @Override
+ @AfterExperiment
protected void tearDown() {
mWriteParcel.recycle();
mWriteParcel = null;
@@ -118,5 +119,4 @@ public class ParcelArrayBenchmark extends SimpleBenchmark {
mLongParcel.readLongArray(mLongArray);
}
}
-
}
diff --git a/core/tests/benchmarks/src/android/os/ParcelBenchmark.java b/core/tests/benchmarks/src/android/os/ParcelBenchmark.java
index 6a7b7c890edb..4bd2d009dcf3 100644
--- a/core/tests/benchmarks/src/android/os/ParcelBenchmark.java
+++ b/core/tests/benchmarks/src/android/os/ParcelBenchmark.java
@@ -16,18 +16,19 @@
package android.os;
-import com.google.caliper.SimpleBenchmark;
+import com.google.caliper.AfterExperiment;
+import com.google.caliper.BeforeExperiment;
-public class ParcelBenchmark extends SimpleBenchmark {
+public class ParcelBenchmark {
private Parcel mParcel;
- @Override
+ @BeforeExperiment
protected void setUp() {
mParcel = Parcel.obtain();
}
- @Override
+ @AfterExperiment
protected void tearDown() {
mParcel.recycle();
mParcel = null;
diff --git a/core/tests/benchmarks/src/android/os/StrictModeBenchmark.java b/core/tests/benchmarks/src/android/os/StrictModeBenchmark.java
index 41af382071ca..a1109062303b 100644
--- a/core/tests/benchmarks/src/android/os/StrictModeBenchmark.java
+++ b/core/tests/benchmarks/src/android/os/StrictModeBenchmark.java
@@ -18,9 +18,7 @@ package android.os;
import android.os.StrictMode.ThreadPolicy;
-import com.google.caliper.SimpleBenchmark;
-
-public class StrictModeBenchmark extends SimpleBenchmark {
+public class StrictModeBenchmark {
private ThreadPolicy mOff = new ThreadPolicy.Builder().build();
private ThreadPolicy mOn = new ThreadPolicy.Builder().detectAll().build();
diff --git a/core/tests/benchmarks/src/android/util/FloatMathBenchmark.java b/core/tests/benchmarks/src/android/util/FloatMathBenchmark.java
index 2858128b3c8d..028dd1d14a18 100644
--- a/core/tests/benchmarks/src/android/util/FloatMathBenchmark.java
+++ b/core/tests/benchmarks/src/android/util/FloatMathBenchmark.java
@@ -15,13 +15,9 @@
*/
package android.util;
-import com.google.caliper.Param;
-import com.google.caliper.Runner;
-import com.google.caliper.SimpleBenchmark;
-
import android.util.FloatMath;
-public class FloatMathBenchmark extends SimpleBenchmark {
+public class FloatMathBenchmark {
public float timeFloatMathCeil(int reps) {
// Keep an answer so we don't optimize the method call away.
@@ -112,5 +108,4 @@ public class FloatMathBenchmark extends SimpleBenchmark {
}
return f;
}
-
}
diff --git a/core/tests/benchmarks/src/com/android/internal/net/NetworkStatsFactoryBenchmark.java b/core/tests/benchmarks/src/com/android/internal/net/NetworkStatsFactoryBenchmark.java
index 2174be5dc0a3..e62fbd6568f7 100644
--- a/core/tests/benchmarks/src/com/android/internal/net/NetworkStatsFactoryBenchmark.java
+++ b/core/tests/benchmarks/src/com/android/internal/net/NetworkStatsFactoryBenchmark.java
@@ -18,29 +18,31 @@ package com.android.internal.net;
import android.net.NetworkStats;
import android.os.SystemClock;
-
-import com.google.caliper.SimpleBenchmark;
-
+import com.google.caliper.AfterExperiment;
+import com.google.caliper.BeforeExperiment;
import java.io.File;
-public class NetworkStatsFactoryBenchmark extends SimpleBenchmark {
+public class NetworkStatsFactoryBenchmark {
private File mStats;
// TODO: consider staging stats file with different number of rows
- @Override
+ @BeforeExperiment
protected void setUp() {
mStats = new File("/proc/net/xt_qtaguid/stats");
}
- @Override
+ @AfterExperiment
protected void tearDown() {
mStats = null;
}
public void timeReadNetworkStatsDetailJava(int reps) throws Exception {
for (int i = 0; i < reps; i++) {
- NetworkStatsFactory.javaReadNetworkStatsDetail(mStats, NetworkStats.UID_ALL);
+ NetworkStatsFactory.javaReadNetworkStatsDetail(mStats, NetworkStats.UID_ALL,
+ // Looks like this was broken by change d0c5b9abed60b7bc056d026bf0f2b2235410fb70
+ // Fixed compilation problem but needs addressing properly.
+ new String[0], 999);
}
}
@@ -48,7 +50,10 @@ public class NetworkStatsFactoryBenchmark extends SimpleBenchmark {
for (int i = 0; i < reps; i++) {
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 0);
NetworkStatsFactory.nativeReadNetworkStatsDetail(
- stats, mStats.getAbsolutePath(), NetworkStats.UID_ALL);
+ stats, mStats.getAbsolutePath(), NetworkStats.UID_ALL,
+ // Looks like this was broken by change d0c5b9abed60b7bc056d026bf0f2b2235410fb70
+ // Fixed compilation problem but needs addressing properly.
+ new String[0], 999);
}
}
}
diff --git a/core/tests/benchmarks/src/com/android/internal/util/IndentingPrintWriterBenchmark.java b/core/tests/benchmarks/src/com/android/internal/util/IndentingPrintWriterBenchmark.java
index 34c73e831923..1112d5c40e95 100644
--- a/core/tests/benchmarks/src/com/android/internal/util/IndentingPrintWriterBenchmark.java
+++ b/core/tests/benchmarks/src/com/android/internal/util/IndentingPrintWriterBenchmark.java
@@ -17,15 +17,15 @@
package com.android.internal.util;
import com.google.android.collect.Lists;
-import com.google.caliper.SimpleBenchmark;
-
+import com.google.caliper.AfterExperiment;
+import com.google.caliper.BeforeExperiment;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
-public class IndentingPrintWriterBenchmark extends SimpleBenchmark {
+public class IndentingPrintWriterBenchmark {
private PrintWriter mDirect;
private IndentingPrintWriter mIndenting;
@@ -33,7 +33,7 @@ public class IndentingPrintWriterBenchmark extends SimpleBenchmark {
private Node mSimple;
private Node mComplex;
- @Override
+ @BeforeExperiment
protected void setUp() throws IOException {
final FileOutputStream os = new FileOutputStream(new File("/dev/null"));
mDirect = new PrintWriter(os);
@@ -49,7 +49,7 @@ public class IndentingPrintWriterBenchmark extends SimpleBenchmark {
manyChildren);
}
- @Override
+ @AfterExperiment
protected void tearDown() {
mIndenting.close();
mIndenting = null;