Commit graph

11 commits

Author SHA1 Message Date
Christopher Ferris
89379355c4 Add a couple of new benchmarks.
Add a calloc benchmark to make sure that a native allocator isn't
doing anything incorrectly when zero'ing memory.

Also add a fork call benchmark to verify that the time to make a
fork call isn't increasing.

Test: Ran benchmarks on walleye and verified that the numbers are not
Test: too variable between runs.
Change-Id: I61d289d277f85ac432a315e539cf6391ea036866
2020-01-29 16:36:14 -08:00
Elliott Hughes
96705e3712 benchmarks: remove more boilerplate.
Many of our benchmarks are basically just "call one function with a
fixed argument". We don't need to keep repeating all the boilerplate for
that.

This also ensures we don't forget the benchmark::DoNotOptimize, which --
in addition to being a good idea in general -- specifically solves the
problem with gettid benchmark and provides a more accurate result by
removing the indirection through a function pointer.

Test: ran benchmarks
Change-Id: Id67535243678cd0d48f51cf25141e2040da9af03
2019-09-26 07:42:23 -07:00
Anders Lewis
a7b0f88997 Implement interface for bionic benchmarks.
Test: Unit tests.
Change-Id: Ic61932f61ddd572e2f045b601f9da6e090cdc45d
2017-08-07 13:16:09 -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
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
Elliott Hughes
212e0e3824 Build our benchmarks against glibc too.
Bug: 18556607
Change-Id: I455ac8b93c0835836180e549486bc52d393ee6a6
2014-12-01 16:43:51 -08: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
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
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
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