static void poolStatInit(PoolStat stat, mps_pool_t pool, size_t objSize) { mps_addr_t s1, s2, s3; stat->pool = pool; stat->objSize = objSize; stat->ncCount = 0; stat->aCount = 0; stat->fCount = 0; /* allocate 3 half-size sentinel objects, freeing the middle one */ /* to leave a bit of space for the control pool */ s1 = allocObject(pool, objSize / 2); stat->min = s1; stat->max = s1; stat->aCount++; s2 = allocObject(pool, objSize / 2); recordNewObjectStat(stat, s2); s3 = allocObject(pool, objSize / 2); recordNewObjectStat(stat, s3); mps_free(pool, s2, objSize / 2); recordFreedObjectStat(stat); }
static void allocMultiple(PoolStat stat) { mps_addr_t objects[allocsPerIteration]; size_t i; /* allocate a few objects, and record stats for them */ for (i = 0; i < allocsPerIteration; i++) { mps_addr_t obj = allocObject(stat->pool, stat->objSize); recordNewObjectStat(stat, obj); objects[i] = obj; } /* free one of the objects, to make the test more interesting */ i = rnd() % allocsPerIteration; mps_free(stat->pool, objects[i], stat->objSize); recordFreedObjectStat(stat); }
static mps_res_t allocMultiple(PoolStat stat) { mps_addr_t objects[contigAllocs]; int i; /* allocate a few objects, and record stats for them */ for (i = 0; i < contigAllocs; i++) { mps_addr_t obj; mps_res_t res = mps_alloc(&obj, stat->pool, stat->objSize); if (res != MPS_RES_OK) return res; recordNewObjectStat(stat, obj); objects[i] = obj; } /* free one of the objects, to make the test more interesting */ i = rnd() % contigAllocs; mps_free(stat->pool, objects[i], stat->objSize); recordFreedObjectStat(stat); return MPS_RES_OK; }