Created
March 16, 2020 23:26
-
-
Save Catfish-Man/b9576c256ba5687f204ae58694ecacc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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