@@ -321,6 +321,15 @@ run_worker(void *(worker_func)(void *arg), struct worker_args args[])
321
321
THREAD_JOIN (& t [i ], NULL );
322
322
}
323
323
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
+
324
333
int
325
334
main (int argc , char * argv [])
326
335
{
@@ -390,17 +399,14 @@ main(int argc, char *argv[])
390
399
391
400
alloc = allocPre ;
392
401
if (enable_stats )
393
- alloc += Ops_per_thread * Threads * ((ALLOC_SIZE / 128 ) + 1 )
394
- * 128 ;
402
+ alloc += allocation_inc (ALLOC_SIZE );
395
403
run_worker (alloc_worker , args );
396
404
ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
397
405
UT_ASSERTeq (alloc , allocPost );
398
406
399
407
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 );
404
410
}
405
411
run_worker (realloc_worker , args );
406
412
ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
@@ -424,16 +430,14 @@ main(int argc, char *argv[])
424
430
ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
425
431
UT_ASSERTeq (alloc , allocPost );
426
432
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 ;
429
434
run_worker (action_publish_worker , args );
430
435
actions_clear (pop , r );
431
436
ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
432
437
UT_ASSERTeq (alloc , allocPost );
433
438
434
439
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 ;
437
441
run_worker (action_mix_worker , args );
438
442
ret = pmemobj_ctl_get (pop , "stats.heap.curr_allocated" , & allocPost );
439
443
UT_ASSERTeq (alloc , allocPost );
0 commit comments