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
// File scope function prototypes
static bool server(void);
// 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);
static void bindCPU(unsigned int cpu);
static ostream &operator<<(ostream &stream, const String16& str);
static ostream &operator<<(ostream &stream, const cpu_set_t& set);
-static void BM_client(benchmark::State& state)
+static void BM_addInts(benchmark::State& state)
int rv;
sp<IServiceManager> sm = defaultServiceManager();
int rv;
sp<IServiceManager> sm = defaultServiceManager();
state.ResumeTiming();
}
}
state.ResumeTiming();
}
}
AddIntsService::AddIntsService(int cpu): cpu_(cpu) {
AddIntsService::AddIntsService(int cpu): cpu_(cpu) {
- ::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);
+ }
+}