public
interface
PerformanceTestCase
android.test.PerformanceTestCase
|
This interface was deprecated
in API level 24.
Use
AndroidJUnitRunner instead. New tests should be written using the
Android Testing Support Library.
More complex interface performance for test cases.
If you want your test to be used as a performance test, you must
implement this interface.
Summary
Nested classes |
interface |
PerformanceTestCase.Intermediates
Callbacks for PerformanceTestCase .
|
Public methods
public abstract boolean isPerformanceOnly ()
This method is used to determine what modes this test case can run in.
Returns |
boolean |
true if this test case can only be run in performance mode. |
public abstract int startPerformance (PerformanceTestCase.Intermediates intermediates)
Set up to begin performance tests. The 'intermediates' is a
communication channel to send back intermediate performance numbers --
if you use it, you will probably want to ensure your test is only
executed once by returning 1. Otherwise, return 0 to allow the test
harness to decide the number of iterations.
If you return a non-zero iteration count, you should call
intermediates.startTiming
and
intermediates.endTiming
to report the
duration of the test whose performance should actually be measured.
Parameters |
intermediates |
PerformanceTestCase.Intermediates : Callback for sending intermediate results. |
Returns |
int |
int Maximum number of iterations to run, or 0 to let the caller
decide. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[],[],null,["# PerformanceTestCase\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nDeprecated in [API level\n24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nPerformanceTestCase\n===================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/test/PerformanceTestCase \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nPerformanceTestCase\n`\n\n\n`\n\n\n`\n\n|----------------------------------|\n| android.test.PerformanceTestCase |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\n**This interface was deprecated\nin API level 24.** \n\nUse\n[AndroidJUnitRunner](/reference/android/support/test/runner/AndroidJUnitRunner) instead. New tests should be written using the\n[Android Testing Support Library](/tools/testing-support-library).\n\nMore complex interface performance for test cases.\n\nIf you want your test to be used as a performance test, you must\nimplement this interface.\n\nSummary\n-------\n\n| ### Nested classes ||\n|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` interface` | [PerformanceTestCase.Intermediates](/reference/android/test/PerformanceTestCase.Intermediates) Callbacks for [PerformanceTestCase](/reference/android/test/PerformanceTestCase). |\n\n| ### Public methods ||\n|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[isPerformanceOnly](/reference/android/test/PerformanceTestCase#isPerformanceOnly())`() ` This method is used to determine what modes this test case can run in. |\n| ` abstract int` | ` `[startPerformance](/reference/android/test/PerformanceTestCase#startPerformance(android.test.PerformanceTestCase.Intermediates))`(`[PerformanceTestCase.Intermediates](/reference/android/test/PerformanceTestCase.Intermediates)` intermediates) ` Set up to begin performance tests. |\n\nPublic methods\n--------------\n\n### isPerformanceOnly\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean isPerformanceOnly ()\n```\n\nThis method is used to determine what modes this test case can run in.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|--------------------------------------------------------------------|\n| `boolean` | true if this test case can only be run in performance mode. \u003cbr /\u003e |\n\n### startPerformance\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract int startPerformance (PerformanceTestCase.Intermediates intermediates)\n```\n\nSet up to begin performance tests. The 'intermediates' is a\ncommunication channel to send back intermediate performance numbers --\nif you use it, you will probably want to ensure your test is only\nexecuted once by returning 1. Otherwise, return 0 to allow the test\nharness to decide the number of iterations.\n\nIf you return a non-zero iteration count, you should call\n[intermediates.startTiming](/reference/android/test/PerformanceTestCase.Intermediates#startTiming(boolean)) and\n[intermediates.endTiming](/reference/android/test/PerformanceTestCase.Intermediates#finishTiming(boolean)) to report the\nduration of the test whose performance should actually be measured.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------------|----------------------------------------------------------------------------------------|\n| `intermediates` | `PerformanceTestCase.Intermediates`: Callback for sending intermediate results. \u003cbr /\u003e |\n\n| Returns ||\n|-------|--------------------------------------------------------------------------------|\n| `int` | int Maximum number of iterations to run, or 0 to let the caller decide. \u003cbr /\u003e |"]]