5 #include "tpmalloc/mymalloc.h"
17 #define HJMALLOCDEBUG 0
18 #define HJMALLOCPROFILE 0
37 std::cout <<
"in malloc of mymalloc" << std::endl;
41 return mymalloc(__size);
45 std::cout <<
"mspace in malloc of mymalloc" << std::endl;
51 struct timespec ts1, ts2;
52 clock_gettime(CLOCK_REALTIME, &ts1);
58 clock_gettime(CLOCK_REALTIME, &ts2);
59 timed = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
67 void *
calloc (
size_t __nmemb,
size_t __size)
74 std::cout <<
"in calloc of mymalloc" << std::endl;
77 return mycalloc(__nmemb, __size);
81 std::cout <<
"mspace in alloc of mymalloc" << std::endl;
87 struct timespec ts1, ts2;
88 clock_gettime(CLOCK_REALTIME, &ts1);
94 clock_gettime(CLOCK_REALTIME, &ts2);
95 timed = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
111 std::cout <<
"in realloc of mymalloc" << std::endl;
114 return myrealloc(__ptr, __size);
118 std::cout <<
"mspace in realloc of mymalloc" << std::endl;
124 struct timespec ts1, ts2;
125 clock_gettime(CLOCK_REALTIME, &ts1);
131 clock_gettime(CLOCK_REALTIME, &ts2);
132 timed = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
147 std::cout <<
"in free of mymalloc" << std::endl;
154 std::cout <<
"mspace in free of mymalloc" << std::endl;
159 struct timespec ts1, ts2;
160 clock_gettime(CLOCK_REALTIME, &ts1);
166 clock_gettime(CLOCK_REALTIME, &ts2);
167 timed = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
181 std::cout <<
"in cfree of mymalloc" << std::endl;
188 std::cout <<
"mspace in cfree of mymalloc" << std::endl;
193 struct timespec ts1, ts2;
194 clock_gettime(CLOCK_REALTIME, &ts1);
200 clock_gettime(CLOCK_REALTIME, &ts2);
201 timed = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
215 std::cout <<
"in valloc of mymalloc" << std::endl;
218 return myvalloc(__size);
222 std::cout <<
"mspace in valloc of mymalloc" << std::endl;
228 struct timespec ts1, ts2;
229 clock_gettime(CLOCK_REALTIME, &ts1);
235 clock_gettime(CLOCK_REALTIME, &ts2);
236 timed = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
void * valloc(size_t __size)
G4ThreadLocal mspace tlms
void * calloc(size_t __nmemb, size_t __size)
void * mspace_malloc(mspace msp, size_t bytes)
G4ThreadLocal double freetime
G4ThreadLocal long int freecount
G4ThreadLocal int mallocswitch
void mspace_free(mspace msp, void *mem)
G4ThreadLocal double alloctime
void * mspace_calloc(mspace msp, size_t n_elements, size_t elem_size)
void * realloc(void *__ptr, size_t __size)
void * malloc(size_t __size)
void * mspace_realloc(mspace msp, void *mem, size_t newsize)
G4ThreadLocal long int alloccount
mspace create_mspace(size_t capacity, int locked)