platform_bionic/benchmarks
Ryan Prichard 3cfb89d451 run-on-host fixes
* Fix the path to bionic-benchmarks-glibc

 * Add symlinks for the toybox symlink commands. Each symlink bypasses the
   intermediate symlink in ${OUT}/system/bin and points to the final
   toybox binary. Suppress a bunch of warnings by skipping symlinks for
   non-existent files.

   The new spawn benchmarks try to run /system/bin/true. (They also try to
   run /vendor/bin/true and print an error.)

 * Quote "$@"

 * Use soong_ui.bash --dumpvars-mode to set a bunch of variables, rather
   than get_build_var, which invokes Soong once per variable. This reduces
   the "build/run-on-host.sh" runtime from 4s to 1.3s.

 * build/run-on-host.sh isn't executable and is only useful when it's
   sourced into another shell, so remove its shebang to reduce confusion.

Bug: none
Test: \
  . build/envsetup.sh
  lunch aosp_x86_64-userdebug
  . bionic/build/run-on-host.sh
  prepare MODULES-IN-bionic MODULES-IN-external-toybox
  /system/bin/true

Change-Id: I59e9a6aca77d35b16bdf51759c5fc7e725bfc67c
2019-09-24 15:36:31 -07:00
..
suites Fix benchmark-tests 2018-08-11 23:43:03 -07:00
test_suites Fix benchmark-tests 2018-08-11 23:43:03 -07:00
tests Fix test failures. 2018-11-07 14:30:55 -08:00
Android.bp Update doc comment about running the benchmarks. 2019-04-23 11:49:13 -07:00
atomic_benchmark.cpp Add benchmarks for heap size retrieval 2018-10-18 17:56:58 -07:00
bionic_benchmarks.cpp Add option to define ranges sets for benchmarks 2018-08-11 00:27:27 +00:00
expf_input.cpp Add expf and exp2f benchmark 2018-06-19 11:34:54 -03:00
get_heap_size_benchmark.cpp Add benchmarks for heap size retrieval 2018-10-18 17:56:58 -07:00
inttypes_benchmark.cpp More benchmarks. 2017-12-19 08:55:40 -08:00
logf_input.cpp Add logf and log2f benchmark 2018-06-19 11:34:54 -03:00
malloc_benchmark.cpp Add malloc benchmarks. 2019-04-05 14:45:15 -07:00
malloc_sql.h Add new malloc benchmarks. 2018-08-14 16:01:58 -07:00
math_benchmark.cpp Add pow benchmark 2018-08-08 18:04:48 -03:00
powf_input.cpp Add powf benchmark 2018-06-19 11:34:54 -03:00
property_benchmark.cpp switch to using android-base/file.h instead of android-base/test_utils.h 2018-11-14 15:46:49 -08:00
pthread_benchmark.cpp Fix/suppress bionic google-explicit-constructor warnings 2019-01-02 11:04:05 -08:00
README.md benchmarks: Update the documentation. 2018-09-13 16:08:18 -07:00
run-on-host.sh run-on-host fixes 2019-09-24 15:36:31 -07:00
semaphore_benchmark.cpp Modernise code to use override specifier 2019-03-29 14:27:27 -07:00
sincosf_input.cpp Add sinf/cosf/sincosf benchmark 2018-06-19 11:34:54 -03:00
stdio_benchmark.cpp switch to using android-base/file.h instead of android-base/test_utils.h 2018-11-14 15:46:49 -08:00
stdlib_benchmark.cpp Add malloc benchmarks. 2019-04-05 14:45:15 -07:00
string_benchmark.cpp Add benchmark for strncmp 2018-08-21 21:04:43 +00:00
time_benchmark.cpp bionic: benchmark: add clock_getres performance tests 2017-12-07 09:41:31 -08:00
unistd_benchmark.cpp Implement interface for bionic benchmarks. 2017-08-07 13:16:09 -07:00
util.cpp Fix bug in --bionic_cpu option handling. 2018-05-04 17:34:35 -07:00
util.h Fix bug in --bionic_cpu option handling. 2018-05-04 17:34:35 -07:00

Bionic Benchmarks

Bionic benchmarks is a command line tool for measuring the runtimes of libc functions. It is built on top of Google benchmarks with some additions to organize tests into suites.

Running the benchmarks

Device benchmarks

$ mma
$ adb remount
$ adb sync
$ adb shell /data/benchmarktest/bionic-benchmarks/bionic-benchmarks
$ adb shell /data/benchmarktest64/bionic-benchmarks/bionic-benchmarks

When operated without specifying an xml file, the default is to run all of the benchmarks in alphabetical order.

You can use --benchmark_filter=getpid to just run benchmarks with "getpid" in their name.

Host benchmarks

See the benchmarks/run-on-host.sh script. The host benchmarks can be run with 32 bit or 64 bit bionic, or the host glibc.

Suites

Suites are stored in the suites/ directory and can be chosen with the command line flag '--bionic_xml'.

To choose a specific xml file, use the --bionic_xml=FILE.XML option. By default, this option searches for the xml file in the suites/ directory. If it doesn't exist in that directory then the file will be found as relative to the current directory. If the option specifies the full path to an xml file such as /data/nativetest/suites/example.xml, it will be used as is.

If no xml file is specified through the command-line option, the default is to use suites/full.xml. However, for the host bionic benchmarks (bionic-benchmarks-glibc), the default is to use suites/host.xml.

Format

The format for a benchmark is:

<fn>
    <name>BM_sample_benchmark</name>
    <cpu><optional_cpu_to_lock></cpu>
    <iterations><optional_iterations_to_run></iterations>
    <args><space separated list of function args|shorthand></args>
</fn>

xml-specified values for iterations and cpu take precedence over those specified via command line (via '--bionic_iterations' and '--bionic_cpu', respectively.)

To make small changes in runs, you can also schedule benchmarks by passing in their name and a space-separated list of arguments via the 'bionic_extra' command line flag, e.g. '--bionic_extra="BM_string_memcpy AT_COMMON_SIZES"' or '--bionic_extra="BM_string_memcmp 32 8 8"'

Note that benchmarks will run normally if extra arguments are passed in, and it will fail with a segfault if too few are passed in.

Shorthand

For the sake of brevity, multiple runs can be scheduled in one xml element by putting one of the following in the args field:

NUM_PROPS
MATH_COMMON
AT_ALIGNED_<ONE|TWO>BUF
AT_<any power of two between 2 and 16384>_ALIGNED_<ONE|TWO>BUF
AT_COMMON_SIZES

Definitions for these can be found in bionic_benchmarks.cpp, and example usages can be found in the suites directory.

Unit Tests

Bionic benchmarks also has its own set of unit tests, which can be run from the binary in /data/nativetest[64]/bionic-benchmarks-tests