| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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. |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 21 | * |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | * If you want your test to be used as a performance test, you must |
| 23 | * implement this interface. |
| Paul Duffin | 2d86c7a | 2018-02-16 13:11:05 +0000 | [diff] [blame] | 24 | * |
| 25 | * @deprecated Use |
| 26 | * <a href="{@docRoot}reference/android/support/test/runner/AndroidJUnitRunner.html"> |
| 27 | * AndroidJUnitRunner</a> instead. New tests should be written using the |
| 28 | * <a href="{@docRoot}tools/testing-support-library/index.html">Android Testing Support Library</a>. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | */ |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 30 | @Deprecated |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | public interface PerformanceTestCase |
| 32 | { |
| 33 | /** |
| 34 | * Callbacks for {@link PerformanceTestCase}. |
| 35 | */ |
| 36 | public interface Intermediates |
| 37 | { |
| 38 | void setInternalIterations(int count); |
| 39 | void startTiming(boolean realTime); |
| 40 | void addIntermediate(String name); |
| 41 | void addIntermediate(String name, long timeInNS); |
| 42 | void finishTiming(boolean realTime); |
| 43 | } |
| 44 | |
| 45 | /** |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 46 | * Set up to begin performance tests. The 'intermediates' is a |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | * communication channel to send back intermediate performance numbers -- |
| 48 | * if you use it, you will probably want to ensure your test is only |
| 49 | * executed once by returning 1. Otherwise, return 0 to allow the test |
| 50 | * harness to decide the number of iterations. |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 51 | * |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | * <p>If you return a non-zero iteration count, you should call |
| 53 | * {@link Intermediates#startTiming intermediates.startTiming} and |
| 54 | * {@link Intermediates#finishTiming intermediates.endTiming} to report the |
| 55 | * duration of the test whose performance should actually be measured. |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 56 | * |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | * @param intermediates Callback for sending intermediate results. |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 58 | * |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | * @return int Maximum number of iterations to run, or 0 to let the caller |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 60 | * decide. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | */ |
| 62 | int startPerformance(Intermediates intermediates); |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 63 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | /** |
| 65 | * This method is used to determine what modes this test case can run in. |
| Stephan Linzner | b51617f | 2016-01-27 18:09:50 -0800 | [diff] [blame] | 66 | * |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | * @return true if this test case can only be run in performance mode. |
| 68 | */ |
| 69 | boolean isPerformanceOnly(); |
| 70 | } |
| 71 | |