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