1 2 // Similar to Cachegrind, check if instrumentation works in the presence 3 // of a client request. Uses a Callgrind request to check this. 4 5 #include "../callgrind.h" 6 some_work(int sum)7int some_work(int sum) 8 { 9 int i; 10 11 for(i=0;i<10;i++) sum += i; /* some dummy work */ 12 13 return sum; 14 } 15 some_callgrind_clreqs()16int some_callgrind_clreqs() 17 { 18 int sum = some_work(0); 19 20 CALLGRIND_ZERO_STATS; 21 22 sum += some_work(sum); 23 24 CALLGRIND_DUMP_STATS; 25 26 sum += some_work(sum); 27 28 CALLGRIND_DUMP_STATS_AT("Please dump here"); 29 30 return some_work(sum); 31 } 32 more_callgrind_clreqs()33int more_callgrind_clreqs() 34 { 35 int sum = some_callgrind_clreqs(); 36 37 CALLGRIND_TOGGLE_COLLECT; 38 39 sum += some_callgrind_clreqs(); 40 41 CALLGRIND_TOGGLE_COLLECT; 42 43 return sum; 44 } 45 46 main(void)47int main(void) 48 { 49 more_callgrind_clreqs(); 50 51 CALLGRIND_STOP_INSTRUMENTATION; 52 53 more_callgrind_clreqs(); 54 55 CALLGRIND_START_INSTRUMENTATION; 56 57 more_callgrind_clreqs(); 58 59 CALLGRIND_STOP_INSTRUMENTATION; 60 61 more_callgrind_clreqs(); 62 63 CALLGRIND_START_INSTRUMENTATION; 64 65 return RUNNING_ON_VALGRIND; 66 } 67 68