Add misc apct perf tests

Includes test for Log.d(), and System.nanoTime().

Also unifies Android.mk format, and package usage.

Change-Id: I90039eff1c2c2d59afe75c4a808a29b67f3176f3
This commit is contained in:
Chris Craik
2016-08-16 13:35:36 -07:00
parent 58a00115d9
commit 51dd1e51ec
10 changed files with 140 additions and 9 deletions

View File

@@ -6,7 +6,9 @@ LOCAL_MODULE_TAGS := tests
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test apct-perftests-utils
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-test \
apct-perftests-utils
LOCAL_PACKAGE_NAME := CorePerfTests

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.core.frameworks.perftests">
package="android.core.perftests">
<application>
<uses-library android:name="android.test.runner" />
@@ -8,6 +8,6 @@
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.core.frameworks.perftests"/>
android:targetPackage="android.core.perftests"/>
</manifest>

View File

@@ -27,7 +27,7 @@ import android.support.test.rule.ActivityTestRule;
import android.view.View;
import android.view.ViewGroup;
import com.android.core.frameworks.perftests.R;
import android.core.perftests.R;
import org.junit.Rule;
import org.junit.Test;

View File

@@ -3,11 +3,13 @@ include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
LOCAL_STATIC_JAVA_LIBRARIES := apct-perftests-utils android-support-test
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-test \
apct-perftests-utils
LOCAL_PACKAGE_NAME := GraphicsPerfTests
include $(BUILD_PACKAGE)

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.frameworks.perftests">
package="android.graphics.perftests">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -16,6 +16,6 @@
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.frameworks.perftests"/>
android:targetPackage="android.graphics.perftests"/>
</manifest>

View File

@@ -30,7 +30,7 @@ import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import com.android.frameworks.perftests.R;
import android.graphics.perftests.R;
import org.junit.Rule;
import org.junit.Test;

View File

@@ -0,0 +1,15 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-test \
apct-perftests-utils
LOCAL_PACKAGE_NAME := MiscPerfTests
include $(BUILD_PACKAGE)

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.misc.perftests">
<application>
<uses-library android:name="android.test.runner" />
<activity android:name="android.perftests.utils.StubActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="android.misc.perftests"/>
</manifest>

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2016 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.
*/
package android.util.perftests;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class LogPerfTest {
private final String[] strings = new String[] {
"This is a test log string 1",
"This is a test log string 2",
"This is a test log string 3",
"This is a test log string 4",
"This is a test log string 5",
};
@Rule
public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
@Test
public void testLogPerf() {
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
int i = 0;
while (state.keepRunning()) {
Log.d("LogPerfTest", strings[(i++) % strings.length]);
}
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2016 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.
*/
package java.lang.perftests;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class SystemPerfTest {
@Rule
public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
@Test
public void testNanoTimePerf() {
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
while (state.keepRunning()) {
System.nanoTime();
}
}
}