1*288bf522SAndroid Build Coastguard Worker #include <sys/prctl.h>
2*288bf522SAndroid Build Coastguard Worker
3*288bf522SAndroid Build Coastguard Worker constexpr int LOOP_COUNT = 100000000;
4*288bf522SAndroid Build Coastguard Worker
Function1()5*288bf522SAndroid Build Coastguard Worker void Function1() {
6*288bf522SAndroid Build Coastguard Worker for (volatile int i = 0; i < LOOP_COUNT; ++i) {
7*288bf522SAndroid Build Coastguard Worker }
8*288bf522SAndroid Build Coastguard Worker }
9*288bf522SAndroid Build Coastguard Worker
main()10*288bf522SAndroid Build Coastguard Worker int main() {
11*288bf522SAndroid Build Coastguard Worker // Run the test in an infinite loop, so if we profile the test manually, the process
12*288bf522SAndroid Build Coastguard Worker // doesn't exit before we attach to it. This scheme also allows simpleperf to control
13*288bf522SAndroid Build Coastguard Worker // how long to profile.
14*288bf522SAndroid Build Coastguard Worker while (true) {
15*288bf522SAndroid Build Coastguard Worker prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("RUN_COMM1"), 0, 0, 0); // NOLINT
16*288bf522SAndroid Build Coastguard Worker Function1();
17*288bf522SAndroid Build Coastguard Worker prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("RUN_COMM2"), 0, 0, 0); // NOLINT
18*288bf522SAndroid Build Coastguard Worker Function1();
19*288bf522SAndroid Build Coastguard Worker }
20*288bf522SAndroid Build Coastguard Worker return 0;
21*288bf522SAndroid Build Coastguard Worker }
22