blob: fc665d514aafa0b0a23e25dcdef2121bc1af77f1 [file] [log] [blame]
njn734b8052007-11-01 04:40:37 +00001// 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
21void my_malloc1(int n)
22{
23 malloc(n);
24}
25
26void my_malloc2(int n)
27{
28 malloc(n);
29}
30
31void my_malloc3(int n)
32{
33 malloc(n);
34}
35
36void a7550(void)
37{
njn466ed6e2009-02-18 05:14:44 +000038 my_malloc1(48000);
39 my_malloc2( 7200);
njn734b8052007-11-01 04:40:37 +000040}
41
42void a450(void)
43{
njn466ed6e2009-02-18 05:14:44 +000044 my_malloc2(2400);
45 my_malloc1( 800);
46 my_malloc2( 800);
njn32397c02007-11-10 04:08:08 +000047 my_malloc1( 400);
njn734b8052007-11-01 04:40:37 +000048}
49
50int main(void)
51{
52 a7550();
53 a450();
njn466ed6e2009-02-18 05:14:44 +000054 my_malloc1(4000); // All sizes are divisible by 16 -- no slop.
55 malloc(16000);
56 my_malloc3(400);
njn734b8052007-11-01 04:40:37 +000057 return 0;
58}