blob: 6501839146cbc1e5b5edf60200a33f5fe0fc61ad [file] [log] [blame] [view]
Anders Lewis814359a2017-08-11 16:07:18 -07001Bionic Benchmarks
2=================
3Bionic benchmarks is a command line tool for measuring the runtimes of libc functions. It is built
4on top of [Google benchmarks](https://github.com/google/benchmark) with some additions to organize
5tests into suites.
6
7Instructions for running these can be found in the platform_bionic README.
8
9## Suites
10
11Suites 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
13file called `full.xml` found in the directory `suites/` bound in the same directory
14as the bionic-benchmarks executable.
15
16To use a different xml file, use the `--bionic_xml=FILE.XML` option. By default, this
17option searches for the xml file in the `suites/` directory. If it doesn't exist
18in that directory then the file will be found as relative to the current
19directory. 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
22If no xml file is specified through the command-line option, the default is to use `suites/full.xml`.
23However, for the host bionic benchmarks (bionic-benchmarks-glibc), the default
24is to use `suites/host.xml`.
25
26### Format
27
28The 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
39xml-specified values for iterations and cpu take precedence over those specified via command line
40(via '--bionic_iterations' and '--bionic_cpu', respectively.)
41
42To make small changes in runs, you can also schedule benchmarks by passing in their name and a
43space-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
46Note that benchmarks will run normally if extra arguments are passed in, and it will fail
47with a segfault if too few are passed in.
48
49### Shorthand
50
51For the sake of brevity, multiple runs can be scheduled in one xml element by putting one of the
52following 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
60Definitions for these can be found in bionic_benchmarks.cpp, and example usages can be found in
61the suites directory.
62
63### Unit Tests
64
65Bionic benchmarks also has its own set of unit tests, which can be run from the binary in
66`/data/nativetest[64]/bionic-benchmarks-tests`