@@ -321,6 +321,15 @@ run_worker(void *(worker_func)(void *arg), struct worker_args args[])
321321 THREAD_JOIN (& t [i ], NULL );
322322}
323323
324+ static inline size_t
325+ allocation_inc (size_t base )
326+ {
327+ size_t result = ((base / 128 ) + 1 ) * 128 ;
328+ result *= Ops_per_thread ;
329+ result *= Threads ;
330+ return result ;
331+ }
332+
324333int
325334main (int argc , char * argv [])
326335{
@@ -390,17 +399,14 @@ main(int argc, char *argv[])
390399
391400 alloc = allocPre ;
392401 if (enable_stats )
393- alloc += Ops_per_thread * Threads * ((ALLOC_SIZE / 128 ) + 1 )
394- * 128 ;
402+ alloc += allocation_inc (ALLOC_SIZE );
395403 run_worker (alloc_worker , args );
396404 ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
397405 UT_ASSERTeq (alloc , allocPost );
398406
399407 if (enable_stats ) {
400- alloc -= Ops_per_thread * Threads * ((ALLOC_SIZE / 128 ) + 1 )
401- * 128 ;
402- alloc += Ops_per_thread * Threads * ((REALLOC_SIZE / 128 ) + 1 )
403- * 128 ;
408+ alloc -= allocation_inc (ALLOC_SIZE );
409+ alloc += allocation_inc (REALLOC_SIZE );
404410 }
405411 run_worker (realloc_worker , args );
406412 ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
@@ -424,16 +430,14 @@ main(int argc, char *argv[])
424430 ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
425431 UT_ASSERTeq (alloc , allocPost );
426432 if (enable_stats && Threads > 1 )
427- alloc += Ops_per_thread / 2 * Threads
428- * ((ALLOC_SIZE / 128 ) + 1 ) * 128 ;
433+ alloc += allocation_inc (ALLOC_SIZE ) / 2 ;
429434 run_worker (action_publish_worker , args );
430435 actions_clear (pop , r );
431436 ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
432437 UT_ASSERTeq (alloc , allocPost );
433438
434439 if (enable_stats && Threads > 1 )
435- alloc += Ops_per_thread / 4 * Threads
436- * ((ALLOC_SIZE / 128 ) + 1 ) * 128 ;
440+ alloc += allocation_inc (ALLOC_SIZE ) / 4 ;
437441 run_worker (action_mix_worker , args );
438442 ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
439443 UT_ASSERTeq (alloc , allocPost );
0 commit comments