#include #include #include #include #include #include #include #define SUPERPAGE_SIZE (2*1024*1024) #define SUPERPAGE_MASK (-SUPERPAGE_SIZE) #define SUPERPAGE_ROUND_UP(a) ((a + SUPERPAGE_SIZE-1) & SUPERPAGE_MASK) #define RUNS0 100000 #define STEP 4 /* KB */ #define START STEP #define MAX (1024*1024) /* KB */ #define RUNS1 RUNS0 #define RUNS2 (RUNS0/20) clock_t testt(boolean_t superpages, int mode, int write, int kb) { static int sum; char *data; unsigned int run, p, p2, i, res; mach_vm_address_t addr = 0; int pages = kb/4; mach_vm_size_t size = SUPERPAGE_ROUND_UP(pages*PAGE_SIZE); /* allocate full superpages */ int kr; kr = mach_vm_allocate(mach_task_self(), &addr, size, VM_FLAGS_ANYWHERE | (superpages? VM_FLAGS_SUPERPAGE_SIZE_2MB : VM_FLAGS_SUPERPAGE_NONE)); if (!addr) return 0; data = (char*)(long)addr; /* touch every base page to make sure everything is mapped and zero-filled */ for (p = 0; p