Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 1 | ActivityManagerPerfTests |
| 2 | |
| 3 | Performance tests for various ActivityManager components, e.g. Services, Broadcasts |
Arthur Eubanks | 2dd6779 | 2018-02-07 15:55:10 -0800 | [diff] [blame] | 4 | * These are only for tests that don't require a target package to test against |
| 5 | * Self-contained perf tests should go in frameworks/base/apct-tests/perftests |
Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 6 | |
Arthur Eubanks | 2dd6779 | 2018-02-07 15:55:10 -0800 | [diff] [blame] | 7 | Command to run tests |
Arthur Eubanks | ca17a8e | 2018-02-20 17:24:36 -0800 | [diff] [blame] | 8 | * atest -v ActivityManagerPerfTests |
Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 9 | |
| 10 | Overview |
| 11 | * The numbers we are trying to measure are end-to-end numbers |
| 12 | * For example, the time it takes from sending an Intent to start a Service |
| 13 | to the time the Service runs its callbacks |
| 14 | * System.nanoTime() is monotonic and consistent between processes, so we use that for measuring time |
Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 15 | * If the test app is involved, it will measure the time and send it back to the instrumentation test |
Arthur Eubanks | 2dd6779 | 2018-02-07 15:55:10 -0800 | [diff] [blame] | 16 | * The time is sent back through a Binder interface in the Intent with the help of Utils.sendTime() |
Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 17 | * Each sent time is tagged with an id since there can be multiple events that send back a time |
Arthur Eubanks | 2dd6779 | 2018-02-07 15:55:10 -0800 | [diff] [blame] | 18 | * Each test will run multiple times to account for variation in test runs |
Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 19 | |
| 20 | Structure |
| 21 | * tests |
| 22 | * Instrumentation test which runs the various performance tests and reports the results |
Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 23 | * test-app |
| 24 | * Target package which contains the Services, BroadcastReceivers, etc. to test against |
| 25 | * Sends the time it measures back to the test package |
Arthur Eubanks | 263d674 | 2017-12-18 13:46:59 -0800 | [diff] [blame] | 26 | * utils |
| 27 | * Utilities that both the instrumentation test and test app can use |
Arthur Eubanks | 2dd6779 | 2018-02-07 15:55:10 -0800 | [diff] [blame] | 28 | |
| 29 | Adding tests |
| 30 | * Example |
| 31 | * Look at tests/src/com/android/frameworks/perftests/am/BroadcastPerfTest and |
| 32 | test-app/src/com/android/frameworks/perftests/amteststestapp/TestBroadcastReceiver |
| 33 | for simple examples using this framework |
| 34 | * Steps |
| 35 | * Add any components you will test against in the target package under |
| 36 | test-app/src/com/android/frameworks/perftests/amteststestapp/ |
| 37 | * Add the test class under tests/src/com/android/frameworks/perftests/am/tests/ |
| 38 | * The class should extend BasePerfTest |
| 39 | * Each test should call runPerfFunction() returning the elapsed time for a single iteration |
| 40 | * The test has access to a Context through mContext |
| 41 | * If you are measuring the time elapsed of something that either starts or ends in the target |
| 42 | package |
| 43 | * The target package can report the time it measures through an ITimeReceiverCallback passed |
| 44 | through an Intent through Utils.sendTime(intent, "tag") |
| 45 | (or however a Binder needs to be passed to the target package) |
| 46 | * The instrumentation test can collect that time by calling getReceivedTimeNs("tag") and |
| 47 | calculate the elapsed time |
| 48 | * Each timestamp sent to the instrumentation test is tagged with a tag since multiple timestamps |
| 49 | can be reported in an iteration |
| 50 | * If the target package should be running before your test logic starts, add startTargetPackage(); |
| 51 | at the beginning of the iteration |
Arthur Eubanks | 886a7bd | 2018-02-26 14:53:56 -0800 | [diff] [blame] | 52 | |
Arthur Eubanks | 2dd6779 | 2018-02-07 15:55:10 -0800 | [diff] [blame] | 53 | * Reporting |
Arthur Eubanks | 886a7bd | 2018-02-26 14:53:56 -0800 | [diff] [blame] | 54 | * Look at internal documentation for how to add new tests to dashboards and receive notification |
| 55 | on regressions |