• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <malloc.h>
2 #include <time.h>
3 #include "test.h"
4 
5 #define SIZE_ALIGN (4 * sizeof(size_t))
6 #define THRESHOLD (0x1c00 * SIZE_ALIGN)
7 #define ITER_TIME 20
8 
main(int argc,char * argv[])9 int main(int argc, char *argv[])
10 {
11 	struct timespec ts[2];
12 
13 	clock_gettime(CLOCK_REALTIME, &ts[0]);
14 	for (int i = 0; i < ITER_TIME; ++i) {
15 		for (size_t size = 0; size < THRESHOLD; size += SIZE_ALIGN + 1) {
16 			void *ptr = malloc(size);
17 			if (!ptr) {
18 				t_error("Malloc failed for size %u\n", size);
19 				return -1;
20 			}
21 			free(ptr);
22 		}
23 	}
24 
25 	return t_status;
26 }
27