1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.test; 18 19 /** 20 * More complex interface performance for test cases. 21 * 22 * If you want your test to be used as a performance test, you must 23 * implement this interface. 24 */ 25 public interface PerformanceTestCase 26 { 27 /** 28 * Callbacks for {@link PerformanceTestCase}. 29 */ 30 public interface Intermediates 31 { setInternalIterations(int count)32 void setInternalIterations(int count); startTiming(boolean realTime)33 void startTiming(boolean realTime); addIntermediate(String name)34 void addIntermediate(String name); addIntermediate(String name, long timeInNS)35 void addIntermediate(String name, long timeInNS); finishTiming(boolean realTime)36 void finishTiming(boolean realTime); 37 } 38 39 /** 40 * Set up to begin performance tests. The 'intermediates' is a 41 * communication channel to send back intermediate performance numbers -- 42 * if you use it, you will probably want to ensure your test is only 43 * executed once by returning 1. Otherwise, return 0 to allow the test 44 * harness to decide the number of iterations. 45 * 46 * <p>If you return a non-zero iteration count, you should call 47 * {@link Intermediates#startTiming intermediates.startTiming} and 48 * {@link Intermediates#finishTiming intermediates.endTiming} to report the 49 * duration of the test whose performance should actually be measured. 50 * 51 * @param intermediates Callback for sending intermediate results. 52 * 53 * @return int Maximum number of iterations to run, or 0 to let the caller 54 * decide. 55 */ startPerformance(Intermediates intermediates)56 int startPerformance(Intermediates intermediates); 57 58 /** 59 * This method is used to determine what modes this test case can run in. 60 * 61 * @return true if this test case can only be run in performance mode. 62 */ isPerformanceOnly()63 boolean isPerformanceOnly(); 64 } 65 66