| Anders Lewis | 814359a | 2017-08-11 16:07:18 -0700 | [diff] [blame] | 1 | Bionic Benchmarks |
| 2 | ================= |
| Elliott Hughes | 0bfcbaf | 2017-08-28 09:18:34 -0700 | [diff] [blame^] | 3 | |
| Anders Lewis | 814359a | 2017-08-11 16:07:18 -0700 | [diff] [blame] | 4 | Bionic benchmarks is a command line tool for measuring the runtimes of libc functions. It is built |
| 5 | on top of [Google benchmarks](https://github.com/google/benchmark) with some additions to organize |
| 6 | tests into suites. |
| 7 | |
| Elliott Hughes | 0bfcbaf | 2017-08-28 09:18:34 -0700 | [diff] [blame^] | 8 | Running the benchmarks |
| 9 | ---------------------- |
| 10 | |
| 11 | ### Device benchmarks |
| 12 | |
| 13 | $ mma |
| 14 | $ adb remount |
| 15 | $ adb sync |
| 16 | $ adb shell /data/nativetest/bionic-benchmarks/bionic-benchmarks |
| 17 | $ adb shell /data/nativetest64/bionic-benchmarks/bionic-benchmarks |
| 18 | |
| 19 | When operated without specifying an xml file, the default is to use the |
| 20 | xml file called full.xml found in the directory `suites/` bound in the |
| 21 | same directory as the bionic-benchmarks executable. |
| 22 | |
| 23 | To use a different xml file, use the `--bionic_xml=FILE.XML` option. By |
| 24 | default, this option searches for the xml file in the `suites/` |
| 25 | directory. If it doesn't exist in that directory then the file will be |
| 26 | found as relative to the current directory. If the option specifies the |
| 27 | full path to an xml file such as `/data/nativetest/suites/example.xml`, |
| 28 | it will be used as is. |
| 29 | |
| 30 | You can use `--benchmark_filter=getpid` to just run benchmarks with "getpid" |
| 31 | in their name. |
| 32 | |
| 33 | ### Host benchmarks |
| 34 | |
| 35 | See the benchmarks/run-on-host.sh script. The default for host tests is |
| 36 | to use the `host.xml` file in the suites directory instead of `full.xml`. |
| 37 | The host benchmarks can be run with 32- or 64-bit bionic, or the host glibc. |
| 38 | |
| Anders Lewis | 814359a | 2017-08-11 16:07:18 -0700 | [diff] [blame] | 39 | |
| 40 | ## Suites |
| 41 | |
| 42 | Suites are stored in the `suites/` directory and can be chosen with the command line flag |
| 43 | '--bionic_xml'. When operated without specifying an xml file, the default is to use the |
| 44 | file called `full.xml` found in the directory `suites/` bound in the same directory |
| 45 | as the bionic-benchmarks executable. |
| 46 | |
| 47 | To use a different xml file, use the `--bionic_xml=FILE.XML` option. By default, this |
| 48 | option searches for the xml file in the `suites/` directory. If it doesn't exist |
| 49 | in that directory then the file will be found as relative to the current |
| 50 | directory. If the option specifies the full path to an xml file such as |
| 51 | `/data/nativetest/suites/example.xml`, it will be used as is. |
| 52 | |
| 53 | If no xml file is specified through the command-line option, the default is to use `suites/full.xml`. |
| 54 | However, for the host bionic benchmarks (bionic-benchmarks-glibc), the default |
| 55 | is to use `suites/host.xml`. |
| 56 | |
| 57 | ### Format |
| 58 | |
| 59 | The format for a benchmark is: |
| 60 | |
| 61 | ``` |
| 62 | <fn> |
| 63 | <name>BM_sample_benchmark</name> |
| 64 | <cpu><optional_cpu_to_lock></cpu> |
| 65 | <iterations><optional_iterations_to_run></iterations> |
| 66 | <args><space separated list of function args|shorthand></args> |
| 67 | </fn> |
| 68 | ``` |
| 69 | |
| 70 | xml-specified values for iterations and cpu take precedence over those specified via command line |
| 71 | (via '--bionic_iterations' and '--bionic_cpu', respectively.) |
| 72 | |
| 73 | To make small changes in runs, you can also schedule benchmarks by passing in their name and a |
| 74 | space-separated list of arguments via the 'bionic_extra' command line flag, e.g. |
| 75 | '--bionic_extra="BM_string_memcpy AT_COMMON_SIZES"' or '--bionic_extra="BM_string_memcmp 32 8 8"' |
| 76 | |
| 77 | Note that benchmarks will run normally if extra arguments are passed in, and it will fail |
| 78 | with a segfault if too few are passed in. |
| 79 | |
| 80 | ### Shorthand |
| 81 | |
| 82 | For the sake of brevity, multiple runs can be scheduled in one xml element by putting one of the |
| 83 | following in the args field: |
| 84 | |
| 85 | NUM_PROPS |
| 86 | MATH_COMMON |
| 87 | AT_ALIGNED_<ONE|TWO>BUF |
| 88 | AT_<any power of two between 2 and 16384>_ALIGNED_<ONE|TWO>BUF |
| 89 | AT_COMMON_SIZES |
| 90 | |
| 91 | Definitions for these can be found in bionic_benchmarks.cpp, and example usages can be found in |
| 92 | the suites directory. |
| 93 | |
| 94 | ### Unit Tests |
| 95 | |
| 96 | Bionic benchmarks also has its own set of unit tests, which can be run from the binary in |
| 97 | `/data/nativetest[64]/bionic-benchmarks-tests` |