Stay organized with collections
Save and categorize content based on your preferences.
interface PerformanceTestCase
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
Public methods |
abstract Boolean |
This method is used to determine what modes this test case can run in.
|
abstract Int |
Set up to begin performance tests.
|
Public methods
abstract fun isPerformanceOnly(): Boolean
Deprecated: Deprecated in Java.
This method is used to determine what modes this test case can run in.
Return |
Boolean |
true if this test case can only be run in performance mode. |
abstract fun startPerformance(intermediates: PerformanceTestCase.Intermediates!): Int
Deprecated: Deprecated in Java.
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.
Return |
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-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# PerformanceTestCase\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nPerformanceTestCase\n===================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/test/PerformanceTestCase \"View this page in Java\") \n\n```\ninterface PerformanceTestCase\n```\n\n|---------------------------------------|\n| [android.test.PerformanceTestCase](#) |\n\n*** ** * ** ***\n\n| **This interface was deprecated in API level 24.**\n|\n| Use [AndroidJUnitRunner](https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library/index.html).\n\nMore complex interface performance for test cases. If you want your test to be used as a performance test, you must implement this interface.\n\nSummary\n-------\n\n| Nested classes ||\n|----------|---------------------------------------------------------------------------------------------------------------------------|\n| abstract | [Intermediates](/reference/kotlin/android/test/PerformanceTestCase.Intermediates) Callbacks for [PerformanceTestCase](#). |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isPerformanceOnly](#isPerformanceOnly())`()` This method is used to determine what modes this test case can run in. |\n| abstract [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [startPerformance](#startPerformance(android.test.PerformanceTestCase.Intermediates))`(`intermediates:` `[PerformanceTestCase.Intermediates](/reference/kotlin/android/test/PerformanceTestCase.Intermediates)!`)` Set up to begin performance tests. |\n\nPublic methods\n--------------\n\n### isPerformanceOnly\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun isPerformanceOnly(): Boolean\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nThis method is used to determine what modes this test case can run in.\n\n| Return ||\n|------------------------------------------------------------------------------------|-------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if this test case can only be run in performance mode. |\n\n### startPerformance\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun startPerformance(intermediates: PerformanceTestCase.Intermediates!): Int\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nSet 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.\n\nIf you return a non-zero iteration count, you should call [intermediates.startTiming](/reference/kotlin/android/test/PerformanceTestCase.Intermediates#startTiming(kotlin.Boolean)) and [intermediates.endTiming](/reference/kotlin/android/test/PerformanceTestCase.Intermediates#finishTiming(kotlin.Boolean)) to report the duration of the test whose performance should actually be measured.\n\n| Parameters ||\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `intermediates` | [PerformanceTestCase.Intermediates](/reference/kotlin/android/test/PerformanceTestCase.Intermediates)!: Callback for sending intermediate results. |\n\n| Return ||\n|----------------------------------------------------------------------------|-------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | int Maximum number of iterations to run, or 0 to let the caller decide. |"]]