lib: bitmap: add performance test for bitmap_print_to_pagebuf

Functional tests for bitmap_print_to_pagebuf() are provided
in lib/test_printf.c. This patch adds performance test for
a case of fully set bitmap.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

+37
+37
lib/test_bitmap.c
··· 446 446 } 447 447 } 448 448 449 + static void __init test_bitmap_printlist(void) 450 + { 451 + unsigned long *bmap = kmalloc(PAGE_SIZE, GFP_KERNEL); 452 + char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 453 + char expected[256]; 454 + int ret, slen; 455 + ktime_t time; 456 + 457 + if (!buf || !bmap) 458 + goto out; 459 + 460 + memset(bmap, -1, PAGE_SIZE); 461 + slen = snprintf(expected, 256, "0-%ld", PAGE_SIZE * 8 - 1); 462 + if (slen < 0) 463 + goto out; 464 + 465 + time = ktime_get(); 466 + ret = bitmap_print_to_pagebuf(true, buf, bmap, PAGE_SIZE * 8); 467 + time = ktime_get() - time; 468 + 469 + if (ret != slen + 1) { 470 + pr_err("bitmap_print_to_pagebuf: result is %d, expected %d\n", ret, slen); 471 + goto out; 472 + } 473 + 474 + if (strncmp(buf, expected, slen)) { 475 + pr_err("bitmap_print_to_pagebuf: result is %s, expected %s\n", buf, expected); 476 + goto out; 477 + } 478 + 479 + pr_err("bitmap_print_to_pagebuf: input is '%s', Time: %llu\n", buf, time); 480 + out: 481 + kfree(buf); 482 + kfree(bmap); 483 + } 484 + 449 485 static const unsigned long parse_test[] __initconst = { 450 486 BITMAP_FROM_U64(0), 451 487 BITMAP_FROM_U64(1), ··· 854 818 test_bitmap_arr32(); 855 819 test_bitmap_parse(); 856 820 test_bitmap_parselist(); 821 + test_bitmap_printlist(); 857 822 test_mem_optimisations(); 858 823 test_for_each_set_clump8(); 859 824 test_bitmap_cut();