blob: 9cb130dbedf8e27c814d8239f41b9329cbcb4ab8 [file] [log] [blame] [view]
Anders Lewis814359a2017-08-11 16:07:18 -07001Bionic Benchmarks
2=================
Elliott Hughes0bfcbaf2017-08-28 09:18:34 -07003
Anders Lewis814359a2017-08-11 16:07:18 -07004Bionic benchmarks is a command line tool for measuring the runtimes of libc functions. It is built
5on top of [Google benchmarks](https://github.com/google/benchmark) with some additions to organize
6tests into suites.
7
Elliott Hughes0bfcbaf2017-08-28 09:18:34 -07008Running 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
19When operated without specifying an xml file, the default is to use the
20xml file called full.xml found in the directory `suites/` bound in the
21same directory as the bionic-benchmarks executable.
22
23To use a different xml file, use the `--bionic_xml=FILE.XML` option. By
24default, this option searches for the xml file in the `suites/`
25directory. If it doesn't exist in that directory then the file will be
26found as relative to the current directory. If the option specifies the
27full path to an xml file such as `/data/nativetest/suites/example.xml`,
28it will be used as is.
29
30You can use `--benchmark_filter=getpid` to just run benchmarks with "getpid"
31in their name.
32
33### Host benchmarks
34
35See the benchmarks/run-on-host.sh script. The default for host tests is
36to use the `host.xml` file in the suites directory instead of `full.xml`.
37The host benchmarks can be run with 32- or 64-bit bionic, or the host glibc.
38
Anders Lewis814359a2017-08-11 16:07:18 -070039
40## Suites
41
42Suites 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
44file called `full.xml` found in the directory `suites/` bound in the same directory
45as the bionic-benchmarks executable.
46
47To use a different xml file, use the `--bionic_xml=FILE.XML` option. By default, this
48option searches for the xml file in the `suites/` directory. If it doesn't exist
49in that directory then the file will be found as relative to the current
50directory. 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
53If no xml file is specified through the command-line option, the default is to use `suites/full.xml`.
54However, for the host bionic benchmarks (bionic-benchmarks-glibc), the default
55is to use `suites/host.xml`.
56
57### Format
58
59The 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
70xml-specified values for iterations and cpu take precedence over those specified via command line
71(via '--bionic_iterations' and '--bionic_cpu', respectively.)
72
73To make small changes in runs, you can also schedule benchmarks by passing in their name and a
74space-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
77Note that benchmarks will run normally if extra arguments are passed in, and it will fail
78with a segfault if too few are passed in.
79
80### Shorthand
81
82For the sake of brevity, multiple runs can be scheduled in one xml element by putting one of the
83following 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
91Definitions for these can be found in bionic_benchmarks.cpp, and example usages can be found in
92the suites directory.
93
94### Unit Tests
95
96Bionic benchmarks also has its own set of unit tests, which can be run from the binary in
97`/data/nativetest[64]/bionic-benchmarks-tests`