Merge "Switch to the latest version of Caliper"
am: ae119af517
* commit 'ae119af517fc427ead5bd6a3394b3b1f92df790d':
Switch to the latest version of Caliper
This commit is contained in:
32
core/tests/benchmarks/Android.mk
Normal file
32
core/tests/benchmarks/Android.mk
Normal file
@@ -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)
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user