Commit graph

181 commits

Author SHA1 Message Date
Elliott Hughes
627329915a Only use NDK libraries in the benchmarks.
It should be possible to run the benchmarks on any device, including
past and future ones, and sticking to NDK libraries ensures that.

Bug: N/A
Test: `readelf -aW`
Change-Id: I15a7a4104fa30263136bc3033d2bd9022cd8ff7b
2018-09-24 16:45:13 -07:00
Christopher Ferris
4fae703029 Touch the memory when doing malloc/free benchmark.
Also, update the benchmark loop for modern C++.

Test: Ran benchmarks.
Change-Id: I925446b893793eb8c2c6759716cdd3dbbcf1e7c1
2018-09-20 15:03:49 -07:00
Peter Collingbourne
ed16b344e7 Merge "benchmarks: Fix the benchmark tests." 2018-09-14 02:16:52 +00:00
Peter Collingbourne
62011c27a7 benchmarks: Update the documentation.
Update the locations of the benchmark binaries to match where they
are currently installed.
2018-09-13 16:08:18 -07:00
Peter Collingbourne
c282ca9f44 benchmarks: Fix the benchmark tests.
Update the list of benchmarks to include the recently added strncmp
benchmarks.
2018-09-13 16:06:01 -07:00
Haibo Huang
e466cc0d55 Add benchmark for strncmp
Test: run benchmark
Change-Id: Id99d81fe4d2a72a7f22414c7eea3ef3d873022ab
2018-08-21 21:04:43 +00:00
Christopher Ferris
0dc784431b Add new malloc benchmarks.
This runs through the trace of the allocations in a sql benchmark app
executed in the benchmark thread.

Add one benchmark with decay time set to 0 and another with decay time
set to 1.

Include a script that can generate a header file that can be used to
regenerate the data.

Bug: 112317428

Test: Builds, ran unit tests, ran benchmarks.
Change-Id: I62e287cc06b74b74bcc5a4bbee71b0fac0a196fd
2018-08-14 16:01:58 -07:00
Haibo Huang
510dda3ea1 Fix benchmark-tests
1. fix all_benchmarks. Some new benchmarks were added.
2. move some benchmark suites to the right place.
3. add unit test for https://android-review.googlesource.com/c/platform/bionic/+/724785

Test: compile and run bionic-benchmarks-tests on device.
Change-Id: I2b686b51910a422b664f9ea968199f37944039c0
2018-08-11 23:43:03 -07:00
Adhemerval Zanella
43f2b77c8b Add new strcmp/strncmp benchmark
This patch adds a new strcmp/strcmp benchmark with different set of
inputs.  It cover all pre-defined range values (small, medium, large)
for aligned inputs and also small range for unaligned ones.

Test: Ran new string test suite with a single bionic iteration.
Change-Id: Ice78d74c3583a33158eaba3309c10df54044aa28
2018-08-11 07:20:53 +00:00
Adhemerval Zanella
0e4fd755a0 Add new memcmp benchmark
This patch adds a new memcmp benchmark with different set of inputs.
It covers all pre-defined range values (small, medium, large) for
aligned inputs and also medium range for unaligned ones.

Test: Ran new string test suite with a single bionic iteration.
Change-Id: Icdb95220a62d46bd71fa6ffbbf4567a9a05b7685
2018-08-11 07:20:13 +00:00
Adhemerval Zanella
eda94aa1ae Add option to define ranges sets for benchmarks
This patch add an option to use the pre-define set of ranges along
with macros AT_ONEBUF_MANUAL_ALIGN_* and AT_TWOBUF_MANUAL_ALIGN1_*.

The size argument can be either a number or a string representing
the sets of values:

  * SMALL for values between 1 and 256.
  * MEDIUM for values between 512 and 128KB.
  * LARGE for values between 256KB and 2048KB.

Test: Ran new string test suite with a single bionic iteration.
Change-Id: Ieda81ee9a5019991b0b2f97d4ca3a237127c5848
2018-08-11 00:27:27 +00:00
Adhemerval Zanella
72fe1c8df6 Add pow benchmark
As for exp/exp2 benchmark, this patch add two benchmark for pow:
one which measures thoughput and one which measures latency.

The input data is the same as powf.

Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: I04335fac9e76fb3f39935323dacf6b7be6a6f917
2018-08-08 18:04:48 -03:00
Adhemerval Zanella
56f4511c39 Add log and log2 benchmark
Similar to exp/exp2, this patch add two benchmarks for log and log2:
one which measures thoughput and one which measures latency.

The input data is based on logf/log2f one (reduced trace based on 2.8
billion samples extracted from specpu2017 521.wrf_r benchmark).

Test: ran 32-bit and 64-bit x86 tests on host

Change-Id: I51a9e2960e45d5619585e685eaa7634cc7be901b
2018-08-08 18:04:48 -03:00
Adhemerval Zanella
10d330af34 Add exp and exp2 benchmark
This patch add two benchmarks for both exp and exp2, one which measures
thoughput and one which measures latency. The latency benchmark works by
creating a dependency on the previous iteration and with a zero multiply
to avoid changing the input value.

The input is based on expf/exp2f benchmark (reduced trace based on 2.4
billion samples extracted from specpu2017 521.wrf_r benchmark).

Test: ran 32-bit and 64-bit x86 tests on host
2018-08-08 15:06:09 -03:00
Yi Kong
32bc0fcf69 Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
2018-08-02 18:09:44 -07:00
Haibo Huang
d5ee4c5fb7 Change args to int64_t
The new benchmark framework uses int64_t for args.

Related benchmark change:
9913418d32 (diff-b9f55422dc0bd52759c6aaa25c305bb0R757)

Upgrade benchmark framework:
https://android-review.googlesource.com/c/platform/external/google-benchmark/+/714118

Test: compile and run bionic benchmark
Change-Id: I1b81c853c28abbead1816bf0be7a20a35e036619
2018-07-07 04:14:22 +00:00
Adhemerval Zanella
7871ca1075 Add sinf/cosf/sincosf benchmark
Similar to expf/exp2f, this patch add two benchmarks for sinf, cosf, and
sincosf: one which measures thoughput as default and one which measures
latency.

The input in 512 random value divided in 8 ranges:

  1. 0.0 <= x < 0.1
  2. 0.1 <= x < 0.7
  3. 0.7 <= x < 3.1
  4. -3.1 <= x < 3.1
  5. 3.3 <= x < 33.3
  6. 100.0 <= x < 1000.0
  7. 1e6 <= x < 1e32
  8. 1e32 < x < FLT_MAX

Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: I92bc2f1fac911c573c5122911d08ca590311578a
2018-06-19 11:34:54 -03:00
Adhemerval Zanella
ff5a353112 Add logf and log2f benchmark
Similar to expf/exp2f, this patch add two benchmarks for logf and log2f:
one which measures thoughput and one which measures latency.

The input data is based on a reduced trace based on 2.8 billion samples
extracted from specpu2017 521.wrf_r benchmark.

Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: If4fbd7eb3d40f8e155935149a82f162b222d5506
2018-06-19 11:34:54 -03:00
Adhemerval Zanella
872c8b5133 Add powf benchmark
As for expf/exp2f benchmark, this patch add two benchmark for powf:
one which measures thoughput and one which measures latency.

The input data is based on a reduced trace from 2.3 billion samples
extracted from specpu2017 521.wrf_r benchmark.

Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: Id8943d90dd5452146e55fb75708daaf7bf0e25fa
2018-06-19 11:34:54 -03:00
Adhemerval Zanella
357f6c1b47 Add expf and exp2f benchmark
This patch add two benchmarks for both expf and exp2f, one which
measures thoughput, as default, and one which measures latency. The
latency benchmark works by creating a dependency on the previous
iteration and with a zero multiply to avoid changing the input value.

The input is based on a reduced trace based on 2.4 billion samples
extracted from specpu2017 521.wrf_r benchmark.

Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: Ic0d40cc4977dd6875fb7431146fc38ea0e6e0bc2
2018-06-19 11:34:54 -03:00
Elliott Hughes
e332f658e0 Switch to FreeBSD's actual sincos.
Before:
  BM_math_sin_fast                48 ns         48 ns   14693053
  BM_math_sincos                  61 ns         61 ns   11470219

After:
  BM_math_sin_fast                48 ns         48 ns   14725120
  BM_math_sincos                  43 ns         43 ns   16329843

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I8693c64135233c0641af5302c38748f47ac76737
2018-05-09 12:25:12 -07:00
Christopher Ferris
bfb7c761d4 Fix bug in --bionic_cpu option handling.
Make sure that all the variables are properly initialized.

Remove the code that verifies the core to enable using get_schedaffinity
since that make it impossible to change the cpu for different tests.

Change the cpu_to_lock to an int, it really didn't need to be a long.

Fix a few missing tests.

Test: Ran unit tests.
Test: Built the tests and ran on different cpus, verifying that the
Test: chosen cpu was correct.
Test: Created an xml file that had different cpus for different tests
Test: and verified that it locked to each cpu properly.
Change-Id: Ie7b4ad8f306f13d6e968d118e71bb5dc0221552a
2018-05-04 17:34:35 -07:00
Tom Cherry
ee8e3dd67c Remove non-trivial constructors/destructors from SystemProperties
With the goal of disallowing exit time destructors, SystemProperties's
non-trivial destructor needs to be removed.  This means replacing the
union hack with yet another hack as we don't want to allocate anything
despite relying on some polymorphism.

Bug: 73485611
Test: boot bullhead
Change-Id: I64223714c9b26c9724bfb8f3e2b0168e47b56bc8
2018-02-21 15:10:17 -08:00
Elliott Hughes
cbc80ba9d8 Switch the rest of our internal headers to #pragma once.
We've been using #pragma once for new internal files, but let's be more bold.

Bug: N/A
Test: builds
Change-Id: I7e2ee2730043bd884f9571cdbd8b524043030c07
2018-02-13 14:27:17 -08:00
Elliott Hughes
d50a1de565 Run bpfmt manually.
Bug: N/A
Test: builds
Change-Id: I0cf145c3b699ac8ef170a63366832f63a9cc1a91
2018-02-05 17:30:57 -08:00
Yabin Cui
5a00ba7c1c Support priority inheritance mutex in 32-bit programs.
Add fast path calling PIMutexTryLock() in pthread_mutex_lock.
Add trace for pi mutex waiting.

Bug: http://b/29177606
Test: run bionic-unit-tests.
Test: run bionic-benchmarks.

Change-Id: I30b6436692d5ea6b63ca9905df745edb843b5528
2018-02-01 16:01:46 -08:00
Yabin Cui
6b9c85b36d Support priority inheritance mutex in 64bit programs.
Bug: http://b/29177606
Test: run bionic-unit-tests on walleye.
Test: run bionic-unit-tests-glibc on host.
Change-Id: Iac349284aa73515f384e7509445f87434757f59e
2018-01-24 16:11:07 -08:00
Elliott Hughes
5cec377f49 Address a bunch of clang-tidy complaints.
There were a bunch more unreasonable/incorrect ones, but these ones
seemed legit. Nothing very interesting, though.

Bug: N/A
Test: ran tests, benchmarks
Change-Id: If66971194d4a7b4bf6d0251bedb88e8cdc88a76f
2018-01-19 15:56:12 -08:00
Christopher Ferris
4c5fde0e5e Remove workaround for running property tests.
Also fix the tests for some missing benchmarks that have been
added recently.

Test: Ran bionic benchmarks tests and all pass.
Test: Ran bionic benchmarks to verify that there are no crashes.
Change-Id: I8501553e8a229c0c6ea81e894e91ac2f5f2fe26c
2018-01-08 16:13:14 -08:00
Elliott Hughes
811a1dd868 Merge "More benchmarks." 2017-12-19 20:23:39 +00:00
Tom Cherry
64d03a287e Add an end-to-end property benchmark.
This change adds an end-to-end property benchmark that finds each
property currently accessible on the system via
__system_property_find().

Test: run this benchmark
Change-Id: I7d20cc9caf36bf3650c3bb3f58500b7df09a908a
2017-12-19 11:25:42 -08:00
Elliott Hughes
7063a838be More benchmarks.
Add a hand-rolled maps line parser as something to compare our realistic
sscanf benchmark against. Also add benchmarks for the ato*/strto* family.

This patch doesn't fix the tests, which seem to have been broken by
the recent google-benchmark upgrade despite the benchmarks themselves
all working just fine. To me that's a final strike against these tests
which are hard to maintain and not obviously useful, but we can worry
about what to do with them -- whether to just delete them or to try to
turn them into tests that actually have some value -- in a separate CL.

Bug: N/A
Test: ran benchmarks
Change-Id: I6c9a77ece98d624baeb049b360876ef5c35ea7f2
2017-12-19 08:55:40 -08:00
Tom Cherry
e275d6d72d Split properties into their own class to make testing better
Reinitializing system properties can result in crashes later in the
program, and is generally not recommended or even supported.  This
change moves the actual logic for system properties into a class that
can be tested in isolation, without reinitializing the actual system
property area used in libc.

Bug: 62197783
Test: boot devices, ensure properties work
Test: system property unit tests and benchmarks
Change-Id: I9ae6e1b56c62f51a4d3fdb5b62b8926cef545649
2017-12-18 15:17:55 -08:00
Elliott Hughes
3b644e932a Trivial scanf benchmarks.
Bug: http://b/68672236
Test: ran benchmarks
Change-Id: I96514be5e67969b65205e953051c524be3626ec4
2017-12-11 14:46:22 -08:00
Mark Salyzyn
6f9c35ded2 bionic: benchmark: add clock_getres performance tests
Provide a means to check vdso kernel performance for all reasoned
combinations of clock_getres, same set of ids as clock_gettime.

Add to suites/vdso.xml

Test: /data/nativetest{64}/bionic-benchmarks-tests/bionic-benchmarks-tests
      /data/benchmarktest{64}/bionic-benchmarks/bionic-benchmarks \
        --bionic_xml=vdso.xml --benchmark_filter=BM_time_clock_getres*
Bug: 63737556
Change-Id: I11ea200f67aec2a2f6ad9284960f2941298da222
2017-12-07 09:41:31 -08:00
Mark Salyzyn
6ffa10f483 bionic: benchmark: additional clock_gettime performance tests
Provide a means to check vdso kernel performance for each of
CLOCK_MONOTONIC (current), CLOCK_MONOTONIC_COARSE,
CLOCK_MONOTONIC_RAW, CLOCK_REALTIME, CLOCK_REALTIME_COARSE,
CLOCK_BOOTTIME.

Add a suites/vdso.xml to select subset of tests impacted by
vdso implementations.

Test: /data/nativetest{64}/bionic-benchmarks-tests/bionic-benchmarks-tests
      /data/benchmarktest{64}/bionic-benchmarks/bionic-benchmarks \
        --bionic_xml=vdso.xml --benchmark_filter=BM_time_clock_gettime*
Bug: 63737556
Change-Id: Ibc48e838e50929527ce8d221dd1a608bf185cbc2
2017-12-07 09:41:13 -08:00
Christopher Ferris
e2188d460b Add new benchmark options.
Add a bunch of extra options to allow greater flexibility for creating
benchmarks. Add a pattern option that can be used to represent any
one buffer or two buffer possibility. This should fully replace the
functionality of microbench.

Add a single option for one buffer benchmarks and two buffer benchmarks
that represents all of the possible options to run a string benchmark.

Add a string test suite that includes all string benchmarks using the
above option.

Test: New unit tests to cover all the new options, and all pass.
Test: Ran new string test suite with a single bionic iteration.
Change-Id: Idb13ea15e44cec626e9f46672ccd648d7ca72ba6
2017-11-30 15:49:45 -08:00
Christopher Ferris
858e33698d Generate all the benchmarks to run.
Instead of requiring the need to maintain a list of all the benchmarks,
add a programmatic way to generate all of the benchmarks.

This generation runs the benchmarks in alphabetical order.

Add a new macro BIONIC_BENCHMARK_WITH_ARG that will be the default argument
to pass to the benchmark. Change the benchmarks that require default arguments.

Add a small example xml file, and remove the full.xml/host.xml files.

Update readme.

Test: Ran new unit tests, verified all tests are added.
Change-Id: I8036daeae7635393222a7a92d18f34119adba745
2017-11-30 09:09:41 -08:00
Christopher Ferris
ad05730143 Fix bionic benchmark unit tests.
Test: Ran unit tests.
Change-Id: I729572b101c7011cde5e7da4a72af7ede719b76b
2017-11-07 15:18:33 -08:00
Elliott Hughes
5305a4d4a7 10x printf speedup.
Android is UTF-8. Don't make everyone pay to convert UTF-8 to ASCII just
so we can recognize '%'. With UTF-8 we can just strchr forwards.

Before:

  ---------------------------------------------------------------
  Benchmark                        Time           CPU Iterations
  ---------------------------------------------------------------
  BM_stdio_printf_literal       1290 ns       1290 ns     442554
  BM_stdio_printf_s             1204 ns       1204 ns     582446
  BM_stdio_printf_d             1206 ns       1206 ns     578311
  BM_stdio_printf_1$s           2263 ns       2263 ns     310002

After:

  ---------------------------------------------------------------
  Benchmark                        Time           CPU Iterations
  ---------------------------------------------------------------
  BM_stdio_printf_literal        178 ns        178 ns    3394001
  BM_stdio_printf_s              246 ns        246 ns    2850284
  BM_stdio_printf_d              252 ns        252 ns    2778610
  BM_stdio_printf_1$s            363 ns        363 ns    1929011

Add missing __find_arguments error checking to the wide variant to match
the regular one.

Also replace various char/wchar_t differences with the macro.

Bug: http://b/67371539
Test: ran tests
Change-Id: I18f122009c22699943ab5d666a98ea594a972c40
2017-11-03 14:19:00 -07:00
Elliott Hughes
928059907b Add basic printf benchmarks.
Bug: http://b/67371539
Test: ran benchmarks
Change-Id: I6ad05540079776b2df4cc8d9c02440c61e42037d
2017-10-26 15:43:34 -07:00
Josh Gao
286b3a8b2d Fix pthread benchmarks.
PauseTiming and ResumeTiming are thread-local, and unbalanced calls to
them leads to obviously bogus results like:

    Benchmark                          Time            CPU Iterations
    -----------------------------------------------------------------
    BM_pthread_exit_and_join      212600 ns    59981418 ns         12
    BM_pthread_create_and_run  212997341 ns -1569132344 ns       1000

Bug: http://b/68170209
Test: ran bionic benchmarks
Change-Id: Ia88cd6af9ff524443850d834a96cf5dd9c7f3ed9
2017-10-24 14:02:54 -07:00
Elliott Hughes
5c6a7bf0dc Remove some legacy declarations from <math.h>.
These are still needed for backwards compatibility with code built by old
versions of the NDK, but we don't need to pollute the headers with them.

Also lose the hand-written code for these. The compiler-generated code
is either the same or better, and no new code is calling these functions
anyway.

Bug: N/A
Test: ran tests
Change-Id: Ib01ad9805034433e0105aec882608cc8e6526f78
2017-10-19 14:15:31 -07:00
Dan Willemsen
ae407e522a Remove default libraries
libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.

Test: m host
Test: mmma bionic
Change-Id: I966e2f88c24fba5e412bee6b6382045a2026a8e4
2017-09-28 16:16:14 -07:00
Elliott Hughes
0bfcbaf4d0 Add new status document, based on internal wiki.
Also start breaking up the monolithic top level README.md, pulling the
32-bit ABI stuff out into its own file, and moving the remaining benchmark
documentation in with the rest of the benchmark documentation.

Bug: N/A
Test: N/A
Change-Id: Ic1b9995e27b5044199ed34883cc0b8faa894df0e
2017-08-29 11:07:36 -07:00
Anders Lewis
814359a880 Update the bionic benchmarks documentation.
Test: NA
Change-Id: I6b804a1655b5cb76f189366070d478680f40c5d1
2017-08-25 10:41:38 -07:00
Christopher Ferris
d9d39be0f0 A few small fix ups.
- Add a default xml file to run if nothing is specified on the command-line.
- Add a way to specify a xml file in suites without having to specify the
  full path name.
- Move all of the test xml files into their own directory.
- Add the suites directory for to glibc benchmarks.
- Add a new test for help data.
- Modify the full suite test to verify the default xml is chosen and use
  the real full.xml instead of the test one. Delete the test_full.xml.
- Move the property tests to the end of the suite.
- Add skipping of xml comments.

Test: Ran the unit tests and ran the bionic benchmarks.
Change-Id: Ie99965f86fe915af0175de46c7780ab79e2b0843
2017-08-24 14:50:03 -07:00
Christopher Ferris
8e410a73d4 Merge "Fix local path assumption in interface_test." 2017-08-24 17:01:56 +00:00
Elliott Hughes
938bece9e0 Benchmark fgetln(3) and getline(3) as well as fgets(3).
On Pixel 2016, there's about 1us overhead for getline versus
fgets. fgetln(3) is worse still because of the intermediate buffering
(though it might actually be better if you were only reading one line
whose length was less than BUFSIZ).

Also use somewhat realistic input for these benchmarks: /dev/zero makes
no sense at all.

Bug: N/A
Test: ran benchmarks
Change-Id: I4a319825a37ac3849014c4c6b31523c1e200c641
2017-08-23 14:03:43 -07:00
Elliott Hughes
d706fe5f9e Fix the stdio fwrite benchmark.
Can't write to a read-only file. (Mode "rw" isn't meaningful, but isn't
considered an error by any libc I know of.)

Bug: http://b/64585477
Test: ran benchmarks
Change-Id: Ifec1d68414bfc8f3cc8d7f912cb135dccb2e7a41
2017-08-23 00:05:21 +00:00
Anders Lewis
4b26f71778 Fix local path assumption in interface_test.
Also fix a couple of other issues with the tests.

Test: Unit tests.
Change-Id: I6c2b2b5fad487460441487cc231a0e4a8d3897c7
2017-08-15 11:04:44 -07:00
Christopher Ferris
30438e4cea Merge "Improve error handling and fix minor bugs in bionic benchmarks." 2017-08-11 02:04:47 +00:00
Christopher Ferris
73c3be2219 Merge "Add musl benchmarks." 2017-08-10 23:44:04 +00:00
Anders Lewis
a98a5fb63e Improve error handling and fix minor bugs in bionic benchmarks.
Test: Unit tests.
Change-Id: I224ae4c7f195176eb8a87deddb2debcbf0f24ba3
2017-08-09 17:24:13 -07:00
Anders Lewis
ac4f4b43a3 Add musl benchmarks.
Test: Unit tests.
Change-Id: Ifb2911825f84b95fe64a803bfabd32fb81210eae
2017-08-09 15:26:37 -07:00
Elliott Hughes
c2223f746c Track tinyxml2 API change.
Bug: http://b/64459264
Test: builds
Change-Id: I02206b9d40571f306ce712345a36c2754ac73a97
2017-08-08 11:23:27 -07:00
Anders Lewis
a7b0f88997 Implement interface for bionic benchmarks.
Test: Unit tests.
Change-Id: Ic61932f61ddd572e2f045b601f9da6e090cdc45d
2017-08-07 13:16:09 -07:00
Christopher Ferris
5fc1f6e887 Really fix the mac build.
I forgot an underscore.

Test: Builds.
Change-Id: Ib7da13dea315822af89c53a569fb0a0c2fd5d321
2017-07-12 23:10:07 -07:00
Christopher Ferris
bad43c7af4 Fix max build.
Test: Built properly.
Change-Id: I37b8ac7d42653617be6611b640a883066257214c
2017-07-12 19:33:54 -07:00
Christopher Ferris
61b7e114dd Merge "Support memory alignment tests for string_benchmark.cpp" 2017-07-12 22:56:13 +00:00
Anders Lewis
f4447b9105 Support memory alignment tests for string_benchmark.cpp
Test: Manually verify that benchmark times are similar and add a unit test.
Change-Id: Idaaeb4c8c3629f797ffd8d0c86c8d7b7b9653181
2017-07-12 13:42:23 -07:00
George Burgess IV
705910094d bionic: fix assorted static analyzer warnings
Warnings:

bionic/libc/bionic/fts.c:722:5: warning: Null passed to a callee that
requires a non-null 1st parameter

bionic/libc/bionic/sched_cpualloc.c:34:25: warning: Result of 'malloc'
is converted to a pointer of type 'cpu_set_t', which is incompatible
with sizeof operand type 'unsigned long'

bionic/linker/linker_main.cpp:315:7: warning: Access to field 'e_type'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')

bionic/linker/linker_main.cpp:493:66: warning: Access to field 'e_phoff'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')

bionic/linker/linker_main.cpp:90:14: warning: Access to field 'next'
results in a dereference of a null pointer (loaded from variable 'prev')

Bug: None
Test: mma; analyzer warnings are gone. CtsBionicTestCases pass.
Change-Id: I699a60c2c6f64c50b9ea06848a680c98a8abb44a
2017-06-28 15:03:15 -07:00
Anders Lewis
1c487e1036 Add benchmarks for strcpy and strcmp.
Test: Ran benchmarks and verified that runtimes were sensible.
Change-Id: I609e3261503a015bfd4982767fef3ce56141aebc
2017-06-14 17:51:54 -07:00
Anders Lewis
a99d052801 Add copy-only, seek-only, and copy-and-seek benchmarks for strcat
Test: Ran benchmarks and verified that runtimes were sensible.
Change-Id: I6da3aaea0ba4817662534b24873993589385e6c5
2017-06-14 15:13:50 -07:00
Anders Lewis
271be9bb7d Split memmove benchmark into separate overlapping (src before dst and dst before src) and non-overlapping tests.
Test: Ran benchmarks and verified that runtimes were sensible.
Change-Id: Ia7fbc5596dfdc162fff2364f4ef6dafe5549b907
2017-06-09 13:30:34 -07:00
Victor Khimenko
4a92ffd302 Stop using __system_property_area__
Apparently that "backdoor" is no longer needed - the proper way is
to reinitialize properties:
    https://android-review.googlesource.com/#/c/181794/24/tests/system_properties_test.cpp

Also removes mentions of libnativehelper test (it no longer uses
__system_property_area__) and removes useless "extern" declaration
(actual use was removed long ago).

Test: refactoring CL, existsing tests still pass

BUG=21852512
BUG=34114501

Change-Id: I2223cab2fcb671ea180ad4470a7aba5c9cd20bd8
2017-03-01 20:43:42 +01:00
Hans Boehm
3f5578708d Add "benchmark" to time atomic operations
The intent here is to confirm that the compiler behaves as expected,
and to guide optimization efforts, particularly where there is a
choice between primitives.

Test: Built and ran benchmark on Angler repeatedly. Manually confirmed
that the compiler behaves roughly as expected.

Change-Id: I059b245d1ba8296e9b28602559b53eafafe0a30f
2017-01-31 10:20:26 -08:00
Elliott Hughes
ea87716696 localtime_r(3) should act as if it calls tzset(3).
See code comment.

Bug: http://b/31339449
Test: ran tests & benchmarks
Change-Id: I6b6a63750ef41664dc4698207e6a53e77cc28cdf
2017-01-11 14:56:04 -08:00
Martijn Coenen
be763d85c8 Fix deprecated range_x() calls.
Test: builds with new libbenchmark.
Change-Id: I91c0e5c1b5cf75b8e551f3c59d83ac9352817c4a
2016-11-15 09:07:11 +01:00
Colin Cross
2722ebb30b Convert bionic benchmarks and tests to Android.bp
The compile-time tests and a few custom libraries for dynamic linker
testing are still compiled in make.

Also converts the make rules to run tests on the host to shell scripts
in tests/run-on-host.sh and benchmarks/run-on-host.sh

Change-Id: I6f174b3a69d58c4ed74d29f4e79332d483681534
2016-07-14 12:30:12 -07:00
Chih-Hung Hsieh
1a5fd9c155 Fix misc-macro-parentheses warnings in bionic.
Add parentheses around macro arguments used beside operators,
or use constexpr for simple constants.
Bug: 28705665

Change-Id: I378c8aad92d3ec8e8c4b0440b5c2c99dfe01ce79
2016-06-10 15:25:49 -07:00
Christopher Ferris
1783941f23 Fix infinite loop if semaphore test is not run.
When using the --benchmark_filter option, all of the test objects
get created, but not all are run. Previously, if this test didn't run
it would get into an infinite loop waiting for the test to complete.
This change only waits for the test to complete if it was actually
executed.

Change-Id: I5151a0b4b3d5349b978e716ec4a02ebd8b4eae00
2016-06-06 14:13:17 -07:00
Chih-Hung Hsieh
956df72eb0 Fix google-explicit-constructor warning.
Bug: 28341362
Change-Id: I85d2f83a3ca35699cfab54e725a64aaf3013c8f1
2016-04-22 10:25:10 -07:00
Elliott Hughes
281e06ba69 Switch bionic over to google-benchmark.
Also removes the old benchmarking library.

Change-Id: I4791ae69fa5dea03644d3d411c60b7c6d1fceae3
2016-03-07 13:50:50 -08:00
Elliott Hughes
939a7e0119 Track rename from base/ to android-base/.
Change-Id: I0a4592945400b1fa6892bf7c1fa8659fd711efa3
2015-12-04 15:27:46 -08:00
Elliott Hughes
f9f4a432ee Revert "Revert "Use compiler builtins for fabs.""
Don't enable the inlines when building libm itself. Otherwise clang gets
upset by seeing both an inline and a non-inline definition.

This reverts commit c5deb0f883.

Change-Id: If7abdb351f5a5549d6a331b33af408e8fcfa9868
2015-08-24 16:05:48 -07:00
Elliott Hughes
c5deb0f883 Revert "Use compiler builtins for fabs."
Use of "extern inline" breaks clang build.

This reverts commit d76f16973a.

Change-Id: I995d0d38c3776f5c50b060f16770741c92a2acac
2015-08-24 21:08:13 +00:00
Elliott Hughes
d76f16973a Use compiler builtins for fabs.
Change-Id: Id3bf761d6dfc187f218b5215c53d76bddc83d50b
2015-08-24 13:32:40 -07:00
Elliott Hughes
b662280aaf Use __builtin_* in <math.h>.
Also remove cruft meant to support long-obsolete compilers. More
benchmarks.

Bug: http://b/23195789
Change-Id: Ief538e41e77a77e8013b2f4f359584e8df2c47d8
2015-08-14 15:20:57 -07:00
Dan Albert
3fe1515e38 Add missing include.
libc++ cleaned up a leaky header.

Change-Id: I5ac0f43a075257a9138a82be379c9cffe96e0ab9
2015-08-11 16:46:26 -07:00
Dan Albert
5341691955 Move up to C++14.
The default standard version is now ahead of us. Stop specifying C++11
so we get that too.

Change-Id: Ic96942cd7fd134118e29b744601b0119e49b6ac4
2015-08-10 16:40:06 -07:00
Elliott Hughes
c217373bd6 Fix unused result errors in bionic.
This lets us use _FORTIFY_SOURCE=2 on the host.

Change-Id: I69f5ff9834bfd595aae6584104bee10c4d8a5eeb
2015-05-13 13:18:04 -07:00
Yabin Cui
dc93db20a9 Change name of rwlock benchmark.
rw_lock is not easy for me to remember, so I prefer changing it to rwlock.

Change-Id: I0784acaca0c3b46c28184a77eb29ffe696f9ea07
2015-03-17 13:38:57 -07:00
Dan Albert
3e87c78543 Revert "Revert "Moving StringPrintf to libbase.""
This reverts commit d2dad2b24f.
2015-03-16 10:06:29 -07:00
Nicolas Geoffray
d2dad2b24f Revert "Moving StringPrintf to libbase."
libbase has been reverted

This reverts commit 7ed5fa1e4d.

Change-Id: I5d8ff8c38ff8c9123e6cee5dc15a101a79e94b2e
2015-03-16 12:19:26 +00:00
Dan Albert
7ed5fa1e4d Moving StringPrintf to libbase.
Change-Id: I47ef28bb294ffb7c7c065c5624417edf23503b77
2015-03-13 22:34:37 -07:00
Christopher Ferris
339ac378ca Allow wildcards to match arg values.
Change-Id: I38230b500bb8f8f69af0d7c740855a401cd12898
2015-02-25 14:56:32 -08:00
Greg Hackmann
567bfb3779 Fix 64-bit benchmark build
The * flag to printf() wants an int instead of size_t, and these are
distinct types on 64-bit.  To accomodate this, make the name column
width helpers return int.

In theory this truncates things, but in practice this only matters if
you have a benchmark with more than INT_MAX characters in its name (in
which case you have bigger problems).

Change-Id: I3338948c25a3a8d84f1ead2f5b457c05da8a01cf
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2015-02-20 11:07:38 -08:00
Christopher Ferris
df4942c04a Refactor the benchmark code.
Changes:
- Modify the benchmarks to derive from a single Benchmark object.
- Rewrite the main iteration code. This includes changing the iteration
  code to use the actual total time calculated by the benchmark as a basis
  for determining whether there are enough iterations instead of using
  the time it takes to run the benchmark.
- Allow benchmarks to take no argument, int, or double.
- Fix the PrettyInt printer for negative integers.
- Modify the max column width name to include the whole name including
  the arg part.
- Reformat property_benchmark.cpp in line with the rest of the code.
- Modify a few of the math benchmarks to take an argument instead of
  separate benchmarks for the same function with different args.
- Create a vector of regex_t structs to represent the args all at
  once instead of when running each benchmark.

This change is in preparation for adding new math based benchmarks.

Tested by running on a nexus flo running at max using the new code
and the old code and comparing. All of the numbers are similar, but
some of the iterations are different due to the slightly different
algorithm used.

Change-Id: I57ad1f3ff083282b9ffeb72e687cab369ce3523a
2015-02-19 14:58:24 -08:00
Mark Salyzyn
5d064464f1 bionic: benchmarks: Add BM_semaphore_sem_post_sem_wait
This test reports the overhead of sem_post to sem_wake for a low thread count
and a high thread count.

Change-Id: Ic30dcc8a78d754979117446bf3a28b7575cabac7
2015-02-12 09:43:58 -08:00
Mark Salyzyn
7e50fb2a68 bionic: benchmarks: Add BM_semaphore_sem_post
This test tries its best to report the producer side underlying futex
wake syscall overhead wthin sem_post. It does not measure the time it
takes for the wakeup to propagate to the consumer. It suffers from
clock_gettime syscall overhead, so subtract that. Lock the CPU speed
for consistent results as we may not reach >50% cpu utilization.

Change-Id: I02fa9dab2e6ac27202f0290115150bd3c8de00f2
2015-02-09 17:05:20 -08:00
Christopher Ferris
941a1a191f Do not build host benchmark code on macs.
Macs don't have clock_gettime, and it doesn't seem worth getting this
to run on the host for mac.

Change-Id: I59d9939acc2ede1308b24a60c4242d45355d967d
2015-01-26 16:54:40 -08:00
Elliott Hughes
14152b9f31 Remove obsolete BUILD_TINY_ANDROID.
Change-Id: If2fc97134340fd09ec2583b666ace2f673cbdf66
2015-01-24 19:01:58 -08:00
Elliott Hughes
8c4994bbc1 Implement __fsetlocking.
The old __isthreaded hack was never very useful on Android because all user
code runs in a VM where there are lots of threads running. But __fsetlocking
lets a caller say "I'll worry about the locking for this FILE*", which is
useful for the normal case where you don't share a FILE* between threads
so you don't need any locking.

Bug: 17154740
Bug: 18593728
Change-Id: I2a8dddc29d3edff39a3d7d793387f2253608a68d
2015-01-21 10:33:30 -08:00
Elliott Hughes
1cf32f83d3 Add a benchmark for using stdio to read a file in /proc.
Change-Id: I12517aae19e36b7c022a11e8807aece61bb0cb9c
2015-01-16 17:08:31 -08:00
Elliott Hughes
8bb020e8e5 Use SI prefixes throughout the benchmark output.
Also switch throughput to GiB/s. I did play with using the new code,
but having consistent units for all results seemed easier to use
anyway (and doesn't require extra code).

Change-Id: I466fd573373bd05619e6f6e6d3dedd7dae0d9362
2015-01-16 13:11:25 -08:00
Elliott Hughes
e48f533c95 Use a vector of benchmarks and new for loop syntax.
Change-Id: Ib1f1250e7786770083ed6a478677a893b2075a93
2015-01-15 17:10:42 -08:00
Colin Cross
a763504f9d bionic benchmarks: limit benchmark run time to 1s real time
The benchmark run loop tries to run until 1s of time has been
accumulated between StartBenchmarkTiming() and StopBenchmarkTiming().
If a majority of the time is spent stopped this can lead to
benchmarks running for very long periods of time.  This can easily
happen when benchmarking something that requires initialization or
cleanup on each iteration.

Modify the loop to run for 1s of real time instead of 1s of
benchmark time.  For existing benchmarks this shouldn't make much
of a difference.

Change-Id: Iaba8a13b4dfc4a5e2cd9992041c9173ea556f9cc
2015-01-15 16:42:20 -08:00
Colin Cross
7b9df19491 bionic benchmarks: export benchmark library
Export libbenchmark for external projects to write benchmarks against.

Change-Id: I3b04a56a62ce517afc0d5e06dc8d28879ada3d30
2015-01-15 16:22:42 -08:00
Yabin Cui
8cf1b30567 Use mmap to create the pthread_internal_t
Add name to mmaped regions.
Add pthread benchmark code.
Allocate pthread_internal_t on regular stack.

Bug: 16847284
Change-Id: Id60835163bb0d68092241f1a118015b5a8f85069
2014-12-19 16:05:29 -08:00