Commit graph

219 commits

Author SHA1 Message Date
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
Dmitriy Ivanov
06b1b8ceac Extract bionic-prepare-run-on-host to inc file.
Make benchmark run-on-host depend on bionic-prepare-run-on-host.

Change-Id: I0bdbf561b2580d607a49b7c83cc273320ac55429
2014-12-02 15:15:34 -08:00
Elliott Hughes
212e0e3824 Build our benchmarks against glibc too.
Bug: 18556607
Change-Id: I455ac8b93c0835836180e549486bc52d393ee6a6
2014-12-01 16:43:51 -08:00
Elliott Hughes
076f69d828 Merge "Benchmark fread/fwrite both buffered and unbuffered." 2014-12-01 21:43:32 +00:00
Elliott Hughes
47dc7c974e Benchmark fread/fwrite both buffered and unbuffered.
Bug: 18556607
Change-Id: I53905aedcea75fe550d9c423fb701c2c9bf8e831
2014-12-01 13:12:18 -08:00
Elliott Hughes
f2bb57cfe3 Fix running the bionic benchmarks on the host.
Bug: 18556607
Change-Id: I4e75bfcde788b43e1926be1b0146acf09b496390
2014-12-01 13:11:38 -08:00
Dan Albert
3a5aeba4bd Switch benchmarks and tests to libc++.
Change-Id: I3b9c8f8c14a1e227e67ae1977cc29b0e8fccef5d
2014-09-30 10:28:30 -07:00
Dan Albert
055a59c3ed Prevent benchmarks from being optimized away.
Change-Id: I2d27b39ecdfc50e78098314567c295a2f113f8d3
2014-09-25 15:43:48 -07:00
Calin Juravle
837a962bf5 Add benchmarks for pthread_rw_locks
Benchmarks for the following sequences:
1) pthread_rwlock_rdlock -> pthread_rwlock_unlock
2) pthread_rwlock_wrlock -> pthread_rwlock_unlock

Change-Id: I8d87d4d8afab8637ea7ff5d23a0b3a81d6d40835
2014-09-16 18:02:30 +01:00
Elliott Hughes
905e6d58aa Start hiding "private/bionic_time.h".
Bug: 15765976
Change-Id: Ibd9cf07067ec8dffe9fda6c3d498d4ab90708220
2014-07-25 12:03:51 -07:00
Elliott Hughes
625993dfbb Use VDSO for clock_gettime(2) and gettimeofday(2).
Bug: 15387103
Change-Id: Ifc3608ea65060c1dc38120b10b6e79874f182a36
2014-07-16 14:27:43 -07:00
Christopher Ferris
53531ccebb Make sure not to construct illegal property names.
Change-Id: I37624e69aec51efd4291f076fb87af3f35d33025
2014-07-15 19:26:28 -07:00
Brigid Smith
28417e6314 Added a __system_property_serial benchmark.
Change-Id: Ifc2116f26acb242f4dcdb6eefe128899a9dc63bb
2014-07-09 15:48:37 -07:00
Brigid Smith
a304476145 Added __system_propery_read benchmark.
Change-Id: Ic0e9118859a013aa04841de25822a81a7fc74b3c
2014-07-09 10:26:17 -07:00
Elliott Hughes
7086ad6919 Cache getpid.
In practice, with this implementation we never need to make a system call.
We get the main thread's tid (which is the same as our pid) back from
the set_tid_address system call we have to make during initialization.
A new pthread will have the same pid as its parent, and a fork child's
main (and only) thread will have a pid equal to its tid, which we get for
free from the kernel before clone returns.

The only time we'd actually have to make a getpid system call now is if
we take a signal during fork and the signal handler calls getpid. (That,
or we call getpid in the dynamic linker while it's still dealing with its
own relocations and hasn't even set up the main thread yet.)

Bug: 15387103
Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
2014-06-20 09:06:57 -07:00
Elliott Hughes
5ab51d0d1a Fix GCC 4.9 complaint about int/size_t mismatch.
Change-Id: Ib13857f98658dc8760cff15adb5829e8e140008a
2014-06-12 12:52:58 -07:00
Elliott Hughes
c0eed72cbf Size the benchmark name column appropriately.
Nobody likes misaligned output.

Change-Id: Ifbfd7beec755e91e204426a96c054d4ea20d3fae
2014-06-11 16:48:29 -07:00
Elliott Hughes
b27a840f4b Add __pure2 to a few more functions, most notably gettid and pthread_self.
Change-Id: I7eee9f26f45130038af09d8285782b07f70a996f
2014-06-11 16:32:10 -07:00
Elliott Hughes
7634db5a06 Add a couple more system call benchmarks.
Bug: 15387103
Change-Id: I13419ddf77d201fdbde4c784259c0cb0dcfb9a77
2014-06-09 18:35:21 -07:00
Serban Constantinescu
a147a1da5c AArch64: libm: Fix ARM64 fenv_t and refactor ARM64 libm implementation.
This patch fixes the ARM64 ABI for libm. fenv_t is now split in 32bit status
and 32bit control. This mirrors the AArch64 FPU control and status
registers (FPCR, FPSR).

The patch also refactors the libm implementation for ARM64 into a finer
grained control over the FPU registers.

Bionic-benchmarks has been expanded with 3 more benchmarks for floating
point operations. The new libm implementation for ARM64 performs better
over all the math benchmarks available.

Change-Id: I2a7f81d6b4e55c91f8a63a4c69614fc8b1bcf2db
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2014-06-09 13:52:28 -07:00
Elliott Hughes
d286796fce Turn on -Wunused and fix the mistakes it uncovers.
Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
2014-06-03 15:22:34 -07:00
Elliott Hughes
5d9a7ba0dc Avoid a system call in 'gettid'.
System calls can be pretty slow. This is mako, which has one of our
lowest latencies:

                       iterations      ns/op
  BM_unistd_getpid       10000000        209
  BM_unistd_gettid      200000000          8

Bug: 15297299 (kernel panic from too many gettid calls)
Bug: 15315766 (excessive gettid overhead in liblogd)
Change-Id: I49656c0fc5b5d092390264a59e4f2c0d8a8b1aeb
2014-06-02 10:32:55 -07:00
Dan Albert
7a39094465 Revert "Removes bionic's dependence on stlport"
This reverts commit 4d35da1df8.

Change-Id: Ie9a2620441edb55dbc5949e13a4b913ea4e66797
2014-05-19 23:46:51 +00:00
Dan Albert
4d35da1df8 Removes bionic's dependence on stlport
Only affects tests/benchmarks. Confirmed passing on arm.

Change-Id: If158e23e8cd06e7597ef6f3c9376f6799b467e62
2014-05-19 11:33:14 -07:00
Elliott Hughes
1728b23965 Switch to g_ for globals.
That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
2014-05-14 10:02:03 -07:00
Christopher Ferris
3347a79664 Add ability to run on host for x86/x86_64.
Change-Id: I063cb71ce0f7247cefacaa653c7b87b7b3e72025
2014-05-01 13:44:57 -07:00
Christopher Ferris
8b1ade5c0b Modify hard-coded directory.
Use the ANDROID_DATA environment variable instead of the hard-coded
directory for these benchmarks.

Change-Id: I00bae7b4a24e81e77fc8f52e1fe99f4d4918f520
2014-05-01 13:10:48 -07:00
Christopher Ferris
345b49a7c0 Build 32/64 bit versions of tests/benchmarks.
Change-Id: I4d146377aac6573a214dfaa5cab5cce8b10538b4
2014-04-22 10:42:12 -07:00
Elliott Hughes
02c78a3867 Reimplement isinf/isnan/fpclassify.
Also move isinf and isnan into libc like everyone else.

Also move fpclassify to libc like the BSDs (but unlike glibc). We need
this to be able to upgrade our float/double/long double parsing to gdtoa.

Also add some missing aliases. We now have all of:

  isnan, __isnan, isnanf, __isnanf, isnanl, __isnanl,
  isinf, __isinf, isinff, __isinff, isinfl, __isinfl,
  __fpclassify, __fpclassifyd, __fpclassifyf, __fpclassifyl.

Bug: 13469877
Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
2014-04-14 14:35:47 -07:00
Elliott Hughes
b28e490b73 Add various benchmarks.
These are based on ones from system/extras/tests/bionic/.

Change-Id: I7b1ae15a2ca5d1031a6a511d97b88125c1770047
2014-03-11 11:20:52 -07:00
Serban Constantinescu
282e232e2a AArch64: Add fixes to bionic/tests
This patch adds minor fixes to the bionic unit tests.

Change-Id: Ie10f33c631ed6c10987923d678711d22931ddb05
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-12-16 17:40:30 -08:00
Colin Cross
bd3efbc9b5 bionic: move benchmarks out of tests directory
Change-Id: I4d054965198af22c9a9c821d1bc53f4e9ea01248
2013-12-10 18:24:30 -08:00