test_swap: donot using random to fill memory region to avoid mismatch

Signed-off-by: Wenchao Hao <haowenchao22@gmail.com>
This commit is contained in:
Wenchao Hao 2024-11-20 14:11:40 +08:00
parent 15b49dd069
commit 754870f548
1 changed files with 3 additions and 5 deletions

View File

@ -36,15 +36,14 @@ int main()
/* fill data */ /* fill data */
for (i = 0; i < SIZE / 8; i += 8) 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 */ /* trigger pageout and get time of pageout */
gettimeofday(&tv_b, NULL); gettimeofday(&tv_b, NULL);
madvise(p, SIZE, MADV_PAGEOUT); madvise(p, SIZE, MADV_PAGEOUT);
gettimeofday(&tv_e, NULL); gettimeofday(&tv_e, NULL);
printf("swp out bandwidth: %ld bytes/ms\n", printf("swp out bandwidth: %ld bytes/ms\n", SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b)));
SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b)));
/* read to trigger swapin and */ /* read to trigger swapin and */
gettimeofday(&tv_b, NULL); gettimeofday(&tv_b, NULL);
@ -52,8 +51,7 @@ int main()
*(c + i) = i; *(c + i) = i;
gettimeofday(&tv_e, NULL); gettimeofday(&tv_e, NULL);
printf("swp in bandwidth: %ld bytes/ms\n", printf("swp in bandwidth: %ld bytes/ms\n", SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b)));
SIZE/(tv_to_ms(tv_e) - tv_to_ms(tv_b)));
pid = fork(); pid = fork();