blob: 15602623e7d5dcb3b2833a8c628fd7b774271d6e [file] [log] [blame]
Arthur Eubanks263d6742017-12-18 13:46:59 -08001ActivityManagerPerfTests
2
3Performance tests for various ActivityManager components, e.g. Services, Broadcasts
Arthur Eubanks2dd67792018-02-07 15:55:10 -08004* 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 Eubanks263d6742017-12-18 13:46:59 -08006
Arthur Eubanks2dd67792018-02-07 15:55:10 -08007Command to run tests
Arthur Eubanksca17a8e2018-02-20 17:24:36 -08008* atest -v ActivityManagerPerfTests
Arthur Eubanks263d6742017-12-18 13:46:59 -08009
10Overview
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 Eubanks263d6742017-12-18 13:46:59 -080015* If the test app is involved, it will measure the time and send it back to the instrumentation test
Arthur Eubanks2dd67792018-02-07 15:55:10 -080016 * The time is sent back through a Binder interface in the Intent with the help of Utils.sendTime()
Arthur Eubanks263d6742017-12-18 13:46:59 -080017 * Each sent time is tagged with an id since there can be multiple events that send back a time
Arthur Eubanks2dd67792018-02-07 15:55:10 -080018* Each test will run multiple times to account for variation in test runs
Arthur Eubanks263d6742017-12-18 13:46:59 -080019
20Structure
21* tests
22 * Instrumentation test which runs the various performance tests and reports the results
Arthur Eubanks263d6742017-12-18 13:46:59 -080023* 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 Eubanks263d6742017-12-18 13:46:59 -080026* utils
27 * Utilities that both the instrumentation test and test app can use
Arthur Eubanks2dd67792018-02-07 15:55:10 -080028
29Adding 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 Eubanks886a7bd2018-02-26 14:53:56 -080052
Arthur Eubanks2dd67792018-02-07 15:55:10 -080053* Reporting
Arthur Eubanks886a7bd2018-02-26 14:53:56 -080054 * Look at internal documentation for how to add new tests to dashboards and receive notification
55 on regressions