/* * usage: time ./testit N * N is a repeat count, set it large enough to get repeatable timings */ #include #include #define ALLOC_MINBITS 3 /* smallest chunk size is 8 bytes */ #define ALLOCSET_NUM_FREELISTS 11 /* number of calls to AllocSetFreeIndex with each result category */ static const int numoccurs[ALLOCSET_NUM_FREELISTS] = { #ifdef USE_64BIT_COUNTS 2139534, 5994692, 5711479, 3289034, 4550931, 2573389, 487566, 588470, 155148, 52750, 202597 #else 5190113, 5663980, 3573261, 4476398, 4246178, 1100634, 386501, 601654, 44884, 52372, 202801 #endif }; extern int AllocSetFreeIndex(size_t size); int main(int argc, char **argv) { int repeat = atoi(argv[1]); while (repeat-- > 0) { int k; for (k = 0; k < ALLOCSET_NUM_FREELISTS; k++) { int n = numoccurs[k]; size_t siz = (1 << (ALLOC_MINBITS + k)); while (n-- > 0) { AllocSetFreeIndex(siz); } } } return 0; }