/***************************** * heap_stats.c * * Measure various heap performance statistics using * heaps of uniformly distributed randoms. * * $ ./heap_stats * -- analyze heap creation -- * size steps * 100 92 * 100 90 * 100 84 * 300 277 * 300 276 * 300 280 * 1000 938 * 1000 932 * 1000 944 * 3000 2811 * 3000 2787 * 3000 2807 * 10000 9389 * 10000 9380 * 10000 9419 * 30000 28257 * 30000 28194 * 30000 28102 * ... which is pretty clearly O(n) * * $Id: heap_stats.c 12567 2007-04-09 16:12:05Z mahoney $ ***************/ #include #include #include #include "utility.h" #include "heap.h" // Make random() start in a different place each time this program runs. void randomize(){ // I'm not confident of this recipe, but it seems to work; // using time(NULL) alone seemed to give nearly the same starting rand(). srand(314159*time(NULL)); } node* make_random_nodelist(int size){ int i, r; node* nodes = (node*) malloc(size*sizeof(node)); heap h; for (i=0; i