1 // This artificial program allocates and deallocates a lot of large objects
2 // on the stack. It is a stress test for Memcheck's set_address_range_perms
3 // (sarp) function. Pretty much all Valgrind versions up to 3.1.X do very
4 // badly on it, ie. a slowdown of at least 100x.
6 // It is representative of tsim_arch, the simulator for the University of
7 // Texas's TRIPS processor, whose performance under Valgrind is dominated by
8 // the handling of one frequently-called function that allocates 8348 bytes
14 #define REPS 1000*1000*10
16 __attribute__((noinline))
19 // This nonsense is just to ensure that the compiler does not optimise
20 // away the stack allocation.
26 assert( 480 == (&big_array[490] - &big_array[10]) );
36 req.tv_nsec = 100*1000*1000; // 0.1s
38 // Pause for a bit so that the native run-time is not 0.00, which leads
39 // to ridiculous slow-down figures.
40 //nanosleep(&req, NULL);
42 for (i = 0; i < REPS; i++) {
45 return ( sum == 0xdeadbeef ? 1 : 0 );