Changeset 454 for trunk/src/t-test1.c
- Timestamp:
- Jun 29, 2014, 7:30:04 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/t-test1.c
r229 r454 27 27 * allocated bins per thread. 28 28 */ 29 /* 30 t-test[12] <n-total> <n-parallel> <n-allocs> <size-max> <bins> 31 32 n-total = total number of threads executed (default 10) 33 n-parallel = number of threads running in parallel (2) 34 n-allocs = number of malloc()'s / free()'s per thread (10000) 35 size-max = max. size requested with malloc() in bytes (10000) 36 bins = number of bins to maintain 37 */ 38 29 39 #if defined(HAVE_CONFIG_H) 30 40 #include "config.h" … … 52 62 53 63 #ifdef USE_SYSTEM_MALLOC 54 #define memalign(a,b) malloc(b) 64 extern void *memalign(size_t boundary, size_t size); 65 /* #define memalign(a,b) malloc(b) */ 55 66 #else 56 67 extern void *memalign(size_t boundary, size_t size); … … 203 214 /* Allocate a bin with malloc(), realloc() or memalign(). r must be a 204 215 random number >= 1024. */ 216 int n_malloc=0, n_memalign=0, n_realloc=0, n_calloc=0; 205 217 206 218 static void … … 219 231 m->ptr = (unsigned char *)memalign(sizeof(int) << r, size); 220 232 /* fprintf(stderr, "FIXME memalign %p\n", m->ptr); */ 233 ++n_memalign; 221 234 } else if(r < 20) { /* calloc */ 222 235 if(m->size > 0) free(m->ptr); … … 232 245 } 233 246 #endif 247 ++n_calloc; 234 248 /* fprintf(stderr, "FIXME calloc %p\n", m->ptr); */ 235 249 } else if(r < 100 && m->size < REALLOC_MAX) { /* realloc */ … … 237 251 m->ptr = realloc(m->ptr, size); 238 252 /* fprintf(stderr, "FIXME realloc %p\n", m->ptr); */ 253 ++n_realloc; 239 254 } else { /* plain malloc */ 240 255 if(m->size > 0) free(m->ptr); 241 256 m->ptr = (unsigned char *)malloc(size); 242 257 /* fprintf(stderr, "FIXME malloc %p\n", m->ptr); */ 258 ++n_malloc; 243 259 } 244 260 if(!m->ptr) { … … 540 556 if (verbose) 541 557 if(n_total%N_TOTAL_PRINT == 0) 542 printf("n_total = %d\n", n_total); 558 printf("n_total = %8d - malloc %12d / memalign %12d / realloc %12d / calloc %12d\n", 559 n_total, 560 n_malloc, n_memalign, n_realloc, n_calloc); 543 561 544 562 } … … 578 596 printf("ptmalloc_init\n"); 579 597 #endif 598 599 if((argc > 1) && (0 == strcmp(argv[1], "-h") || 0 == strcmp(argv[1], "--help"))) 600 { 601 printf("%s <n-total> <n-parallel> <n-allocs> <size-max> <bins>\n\n", argv[0]); 602 printf(" n-total = total number of threads executed (default 10)\n"); 603 printf(" n-parallel = number of threads running in parallel (2)\n"); 604 printf(" n-allocs = number of malloc()'s / free()'s per thread (10000)\n"); 605 printf(" size-max = max. size requested with malloc() in bytes (10000)\n"); 606 printf(" bins = number of bins to maintain\n"); 607 return 0; 608 } 580 609 581 610 if(argc > 1) n_total_max = atoi(argv[1]);
Note:
See TracChangeset
for help on using the changeset viewer.