Switch bionic over to google-benchmark.

Also removes the old benchmarking library.

Change-Id: I4791ae69fa5dea03644d3d411c60b7c6d1fceae3
diff --git a/benchmarks/string_benchmark.cpp b/benchmarks/string_benchmark.cpp
index 866aa00..c04409d 100644
--- a/benchmarks/string_benchmark.cpp
+++ b/benchmarks/string_benchmark.cpp
@@ -17,7 +17,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
 
 #define KB 1024
 #define MB 1024*KB
@@ -27,87 +27,77 @@
 
 // TODO: test unaligned operation too? (currently everything will be 8-byte aligned by malloc.)
 
-BENCHMARK_WITH_ARG(BM_string_memcmp, int)->AT_COMMON_SIZES;
-void BM_string_memcmp::Run(int iters, int nbytes) {
-  StopBenchmarkTiming();
+static void BM_string_memcmp(benchmark::State& state) {
+  const size_t nbytes = state.range_x();
   char* src = new char[nbytes]; char* dst = new char[nbytes];
   memset(src, 'x', nbytes);
   memset(dst, 'x', nbytes);
-  StartBenchmarkTiming();
 
   volatile int c __attribute__((unused)) = 0;
-  for (int i = 0; i < iters; ++i) {
+  while (state.KeepRunning()) {
     c += memcmp(dst, src, nbytes);
   }
 
-  StopBenchmarkTiming();
-  SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+  state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
   delete[] src;
   delete[] dst;
 }
+BENCHMARK(BM_string_memcmp)->AT_COMMON_SIZES;
 
-BENCHMARK_WITH_ARG(BM_string_memcpy, int)->AT_COMMON_SIZES;
-void BM_string_memcpy::Run(int iters, int nbytes) {
-  StopBenchmarkTiming();
+static void BM_string_memcpy(benchmark::State& state) {
+  const size_t nbytes = state.range_x();
   char* src = new char[nbytes]; char* dst = new char[nbytes];
   memset(src, 'x', nbytes);
-  StartBenchmarkTiming();
 
-  for (int i = 0; i < iters; ++i) {
+  while (state.KeepRunning()) {
     memcpy(dst, src, nbytes);
   }
 
-  StopBenchmarkTiming();
-  SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+  state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
   delete[] src;
   delete[] dst;
 }
+BENCHMARK(BM_string_memcpy)->AT_COMMON_SIZES;
 
-BENCHMARK_WITH_ARG(BM_string_memmove, int)->AT_COMMON_SIZES;
-void BM_string_memmove::Run(int iters, int nbytes) {
-  StopBenchmarkTiming();
+static void BM_string_memmove(benchmark::State& state) {
+  const size_t nbytes = state.range_x();
   char* buf = new char[nbytes + 64];
   memset(buf, 'x', nbytes + 64);
-  StartBenchmarkTiming();
 
-  for (int i = 0; i < iters; ++i) {
+  while (state.KeepRunning()) {
     memmove(buf, buf + 1, nbytes); // Worst-case overlap.
   }
 
-  StopBenchmarkTiming();
-  SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+  state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
   delete[] buf;
 }
+BENCHMARK(BM_string_memmove)->AT_COMMON_SIZES;
 
-BENCHMARK_WITH_ARG(BM_string_memset, int)->AT_COMMON_SIZES;
-void BM_string_memset::Run(int iters, int nbytes) {
-  StopBenchmarkTiming();
+static void BM_string_memset(benchmark::State& state) {
+  const size_t nbytes = state.range_x();
   char* dst = new char[nbytes];
-  StartBenchmarkTiming();
 
-  for (int i = 0; i < iters; ++i) {
+  while (state.KeepRunning()) {
     memset(dst, 0, nbytes);
   }
 
-  StopBenchmarkTiming();
-  SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+  state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
   delete[] dst;
 }
+BENCHMARK(BM_string_memset)->AT_COMMON_SIZES;
 
-BENCHMARK_WITH_ARG(BM_string_strlen, int)->AT_COMMON_SIZES;
-void BM_string_strlen::Run(int iters, int nbytes) {
-  StopBenchmarkTiming();
+static void BM_string_strlen(benchmark::State& state) {
+  const size_t nbytes = state.range_x();
   char* s = new char[nbytes];
   memset(s, 'x', nbytes);
   s[nbytes - 1] = 0;
-  StartBenchmarkTiming();
 
   volatile int c __attribute__((unused)) = 0;
-  for (int i = 0; i < iters; ++i) {
+  while (state.KeepRunning()) {
     c += strlen(s);
   }
 
-  StopBenchmarkTiming();
-  SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+  state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
   delete[] s;
 }
+BENCHMARK(BM_string_strlen)->AT_COMMON_SIZES;