Skip to content

Instantly share code, notes, and snippets.

@Catfish-Man
Created March 16, 2020 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Catfish-Man/b9576c256ba5687f204ae58694ecacc2 to your computer and use it in GitHub Desktop.
Save Catfish-Man/b9576c256ba5687f204ae58694ecacc2 to your computer and use it in GitHub Desktop.
#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