njn | 734b805 | 2007-11-01 04:40:37 +0000 | [diff] [blame] | 1 | // When we cull and compute the new minimum time between snapshots, we want |
| 2 | // to ignore any gap between two uncullable snapshots, because it is not |
| 3 | // representative. This program tests that. |
| 4 | |
| 5 | |
| 6 | #include <stdlib.h> |
| 7 | |
| 8 | int main(void) |
| 9 | { |
| 10 | int i; |
| 11 | |
| 12 | // The peak is from the first allocation. |
njn | 32397c0 | 2007-11-10 04:08:08 +0000 | [diff] [blame] | 13 | int* x = malloc(1024); |
njn | 734b805 | 2007-11-01 04:40:37 +0000 | [diff] [blame] | 14 | free(x); |
| 15 | |
| 16 | // Now do an allocation to provide the post-peak baseline. |
njn | 32397c0 | 2007-11-10 04:08:08 +0000 | [diff] [blame] | 17 | malloc(512); |
njn | 734b805 | 2007-11-01 04:40:37 +0000 | [diff] [blame] | 18 | |
| 19 | // Now we do lots of allocations below the peak. With the proper |
| 20 | // handling, the allocations should still be smoothly distributed. |
| 21 | // Without it, the snapshots in the second half of the graph would be |
| 22 | // clustered much more closely than those in the first half. |
| 23 | // |
| 24 | |
| 25 | for (i = 0; i < 350; i++) { |
njn | 32397c0 | 2007-11-10 04:08:08 +0000 | [diff] [blame] | 26 | int* y = malloc(256); |
njn | 734b805 | 2007-11-01 04:40:37 +0000 | [diff] [blame] | 27 | free(y); |
| 28 | } |
| 29 | |
| 30 | return 0; |
| 31 | } |