Android Performance Testing Part I

Posted: August 8, 2009 in Uncategorized

o  I am finishing up my template creation for the AndCooper Android Application Build Tool so that I can submit another TDD bgu fix for the Android SDK and finalize up AndCoooper 0.1. My  performance TestCase looks like this before I transform it into ctl template language constructs:

package com.mobilebytes.mymapview;

import android.test.AndroidTestCase;
import android.test.PerformanceTestCase;

/**
 * This PerformanceTest TestCase class is
 * launched with
 * adb shell am instrument -w -e perf true ${application-package}.tests/android.test.InstrumentationTestRunner
 */
public class PerformanceTest extends AndroidTestCase implements
PerformanceTestCase{

	@Override
	public boolean isPerformanceOnly() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public int startPerformance(Intermediates intermediates) {
		intermediates.startTiming(true);

		// TODO Auto-generated method stub

		intermediates.finishTiming(true);
		return 0;
	}

}

And my ant target looks like this:

	<target name="tests.performance" depends="reinstall" description="tests perforrmance">
								    <echo>Building and installing tests..</echo>
								    <exec executable="ant" failonerror="true">
								        <arg value="-f" />
								        <arg value="tests/build.xml" />
								        <arg value="reinstall"/>
								    </exec>
								    <mkdir dir="${basedir}/log" />
								    <exec executable="${adb}">
								    <arg value="shell" />
								    <arg value="am" />
								    <arg value="instrument" />
								    <arg value="-w" />
								    <arg value="-e" />
								    <arg value="perf"/>
								    <arg value="true"/>
								    <arg value="${application-package}.tests/android.test.InstrumentationTestRunner" />
								    </exec>
			        </target>

what is the difference between this and Monkey UI testing? Monkey UI sends random UI events, you can control the percentage per UI event category. Performance TestCase would be for when you have narrowed down some user cases that need optimization and thus you are setting up timing test which may focus on UI events for that user case and other events testing of that user case.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s