summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2016-08-09 13:06:21 -0700
committerJohn Reck <jreck@google.com>2016-08-09 13:06:21 -0700
commit187816e5793ad177f6f70fe6270baf1475d74149 (patch)
tree73486259ee00625a16c554b4de361f618b891b60
parent17985b261d49ea1c15c0dc306df948e25d1b81b4 (diff)
downloadextras-187816e5793ad177f6f70fe6270baf1475d74149.tar.gz
Fix binderAddInts benchmark
Bug: 30765667 Restores the fork() that was missed in a refactor causing the benchmark to no longer measure binder's IPC performance. Change-Id: Id79ab082f1d20e1d058f80bd43018c9737b8250b
-rw-r--r--tests/binder/benchmarks/binderAddInts.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/tests/binder/benchmarks/binderAddInts.cpp b/tests/binder/benchmarks/binderAddInts.cpp
index d0b2910b..7ac53601 100644
--- a/tests/binder/benchmarks/binderAddInts.cpp
+++ b/tests/binder/benchmarks/binderAddInts.cpp
@@ -79,7 +79,7 @@ class AddIntsService : public BBinder
// File scope function prototypes
static bool server(void);
-static void BM_client(benchmark::State& state);
+static void BM_addInts(benchmark::State& state);
static void bindCPU(unsigned int cpu);
static ostream &operator<<(ostream &stream, const String16& str);
static ostream &operator<<(ostream &stream, const cpu_set_t& set);
@@ -103,9 +103,8 @@ static bool server(void)
return true;
}
-static void BM_client(benchmark::State& state)
+static void BM_addInts(benchmark::State& state)
{
- server();
int rv;
sp<IServiceManager> sm = defaultServiceManager();
@@ -162,7 +161,7 @@ static void BM_client(benchmark::State& state)
state.ResumeTiming();
}
}
-BENCHMARK(BM_client);
+BENCHMARK(BM_addInts);
AddIntsService::AddIntsService(int cpu): cpu_(cpu) {
@@ -305,6 +304,30 @@ int main(int argc, char *argv[])
}
}
- ::benchmark::RunSpecifiedBenchmarks();
-}
+ fflush(stdout);
+ switch (pid_t pid = fork()) {
+ case 0: // Child
+ ::benchmark::RunSpecifiedBenchmarks();
+ return 0;
+
+ default: // Parent
+ if (!server()) { break; }
+
+ // Wait for all children to end
+ do {
+ int stat;
+ rv = wait(&stat);
+ if ((rv == -1) && (errno == ECHILD)) { break; }
+ if (rv == -1) {
+ cerr << "wait failed, rv: " << rv << " errno: "
+ << errno << endl;
+ perror(NULL);
+ exit(8);
+ }
+ } while (1);
+ return 0;
+ case -1: // Error
+ exit(9);
+ }
+}