Home | History | Annotate | Download | only in tests
      1 // This test is for testing that the --threshold options in both Massif and
      2 // ms_print work as they should.  A threshold of 10% is a good choice for
      3 // this file, because in some parts of the tree it renders all children
      4 // insignificant, and in others parts of the tree it renders only some
      5 // children insignificant.
      6 //
      7 // Also, it's deliberate that the 'malloc(2000)' and 'my_malloc1(500)' calls
      8 // are in 'main' -- at one point, ms_print was failing to connect some
      9 // children arrows when a more significant child didn't have any children of
     10 // its own, eg:
     11 //
     12 //   |
     13 //   ->20.00% (2000B) 0x804846A: main (thresholds.c:43)
     14 //
     15 //   ->13.00% (1300B) 0x80483A4: my_malloc2 (thresholds.c:16)
     16 //
     17 // (There must be a '|' between the '->'s.)
     18 
     19 #include <stdlib.h>
     20 
     21 void my_malloc1(int n)
     22 {
     23    malloc(n);
     24 }
     25 
     26 void my_malloc2(int n)
     27 {
     28    malloc(n);
     29 }
     30 
     31 void my_malloc3(int n)
     32 {
     33    malloc(n);
     34 }
     35 
     36 void a7550(void)
     37 {
     38    my_malloc1(48000);
     39    my_malloc2( 7200);
     40 }
     41 
     42 void a450(void)
     43 {
     44    my_malloc2(2400);
     45    my_malloc1( 800);
     46    my_malloc2( 800);
     47    my_malloc1( 400);
     48 }
     49 
     50 int main(void)
     51 {
     52    a7550();
     53    a450();
     54    my_malloc1(4000);       // All sizes are divisible by 16 -- no slop.
     55    malloc(16000);
     56    my_malloc3(400);
     57    return 0;
     58 }
     59