Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#import <stdlib.h>
#import <malloc/malloc.h>
#define SLOW 1
int main(int argc, const char * argv[]) {
#if SLOW
int sizes[] = { 256032, 512032, 1024032, 1792032 };
for (int ii = 0; ii < 10000; ii++) {
void *previous = NULL;
for (int i = 0; i < 4 ; i++) {
void *next = calloc(1, sizes[i]);
free(previous);
previous = next;
}
free(previous);
}
#else
int sizes[] = { 160032, 320032, 480032, 640032, 800032, 960032, 1120032, 1280032 };
for (int ii = 0; ii < 10000; ii++) {
void *previous = NULL;
for (int i = 0; i < 8 ; i++) {
void *next = calloc(1, sizes[i]);
free(previous);
previous = next;
}
free(previous);
}
#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment