From d325d9f4b0514f1658138e1ee92c37a85db4660a Mon Sep 17 00:00:00 2001 From: Wenchao Hao Date: Wed, 20 Nov 2024 14:11:40 +0800 Subject: [PATCH] test_swap: donot using random to fill memory region to avoid mismatch Signed-off-by: Wenchao Hao --- test_swap.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test_swap.c b/test_swap.c index 7d650c2..581fd3a 100644 --- a/test_swap.c +++ b/test_swap.c @@ -36,15 +36,14 @@ int main() /* fill data */ for (i = 0; i < SIZE / 8; i += 8) - *(p + i) = (unsigned long)rand() << 32 | rand(); + *(p + i) = 0xffff + i; /* trigger pageout and get time of pageout */ gettimeofday(&tv_b, NULL); madvise(p, SIZE, MADV_PAGEOUT); gettimeofday(&tv_e, NULL); - printf("swp out bandwidth: %ld bytes/ms\n", - SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b))); + printf("swp out bandwidth: %ld bytes/ms\n", SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b))); /* read to trigger swapin and */ gettimeofday(&tv_b, NULL); @@ -52,8 +51,7 @@ int main() *(c + i) = i; gettimeofday(&tv_e, NULL); - printf("swp in bandwidth: %ld bytes/ms\n", - SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b))); + printf("swp in bandwidth: %ld bytes/ms\n", SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b))); pid = fork();