Skip to content

Commit 187816e

Browse files
committed
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
1 parent 17985b2 commit 187816e

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

tests/binder/benchmarks/binderAddInts.cpp

+29-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class AddIntsService : public BBinder
7979

8080
// File scope function prototypes
8181
static bool server(void);
82-
static void BM_client(benchmark::State& state);
82+
static void BM_addInts(benchmark::State& state);
8383
static void bindCPU(unsigned int cpu);
8484
static ostream &operator<<(ostream &stream, const String16& str);
8585
static ostream &operator<<(ostream &stream, const cpu_set_t& set);
@@ -103,9 +103,8 @@ static bool server(void)
103103
return true;
104104
}
105105

106-
static void BM_client(benchmark::State& state)
106+
static void BM_addInts(benchmark::State& state)
107107
{
108-
server();
109108
int rv;
110109
sp<IServiceManager> sm = defaultServiceManager();
111110

@@ -162,7 +161,7 @@ static void BM_client(benchmark::State& state)
162161
state.ResumeTiming();
163162
}
164163
}
165-
BENCHMARK(BM_client);
164+
BENCHMARK(BM_addInts);
166165

167166

168167
AddIntsService::AddIntsService(int cpu): cpu_(cpu) {
@@ -305,6 +304,30 @@ int main(int argc, char *argv[])
305304
}
306305
}
307306

308-
::benchmark::RunSpecifiedBenchmarks();
309-
}
307+
fflush(stdout);
308+
switch (pid_t pid = fork()) {
309+
case 0: // Child
310+
::benchmark::RunSpecifiedBenchmarks();
311+
return 0;
312+
313+
default: // Parent
314+
if (!server()) { break; }
315+
316+
// Wait for all children to end
317+
do {
318+
int stat;
319+
rv = wait(&stat);
320+
if ((rv == -1) && (errno == ECHILD)) { break; }
321+
if (rv == -1) {
322+
cerr << "wait failed, rv: " << rv << " errno: "
323+
<< errno << endl;
324+
perror(NULL);
325+
exit(8);
326+
}
327+
} while (1);
328+
return 0;
310329

330+
case -1: // Error
331+
exit(9);
332+
}
333+
}

0 commit comments

Comments
 (0)