diff options
| author | sunyi <279644543@qq.com> | 2026-07-06 17:29:33 +0800 |
|---|---|---|
| committer | Yury Norov <ynorov@nvidia.com> | 2026-07-22 15:38:36 -0400 |
| commit | 199dc60543109ad2b7b5904297a3ff54d5a7a0b3 (patch) | |
| tree | 2984617a731c9e4b864e791245503927294a6326 /lib/find_bit_benchmark.c | |
| parent | e61575a62fae531e7c656a35e4c19f15f4ca3e1d (diff) | |
| download | linux-next-199dc60543109ad2b7b5904297a3ff54d5a7a0b3.tar.gz linux-next-199dc60543109ad2b7b5904297a3ff54d5a7a0b3.zip | |
lib: bitmap: add tests for bitmap_find_next_zero_area_off()
Add functional and performance tests
for bitmap_find_next_zero_area_off().
performance tests partial output:
Start testing find_bit() with random-filled bitmap
[ 0.310073] bitmap_find_next_zero_area_off: 852731 ns, 1154 iterations
[ 0.311435] find_next_bit: 1356654 ns, 163975 iterations
Start testing find_bit() with sparse bitmap
[ 0.316267] bitmap_find_next_zero_area_off:4426808 ns, 322479 iterations
[ 0.316292] find_next_bit: 15154 ns, 656 iterations
Signed-off-by: sunyi <279644543@qq.com>
Signed-off-by: Yury Norov <ynorov@nvidia.com>
Diffstat (limited to 'lib/find_bit_benchmark.c')
| -rw-r--r-- | lib/find_bit_benchmark.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c index 00d9dc61cd46..05305e655f99 100644 --- a/lib/find_bit_benchmark.c +++ b/lib/find_bit_benchmark.c @@ -149,6 +149,21 @@ static int __init test_find_next_and_bit(const void *bitmap, return 0; } +static int __init +test_bitmap_find_next_zero_area_off(unsigned long *bitmap, unsigned long len) +{ + unsigned long i, cnt; + ktime_t time; + + time = ktime_get(); + for (cnt = i = 0; i < BITMAP_LEN; cnt++) + i = bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN, i, 8, 0, 0) + 1; + time = ktime_get() - time; + pr_err("bitmap_find_next_zero_area_off:%7llu ns, %6ld iterations\n", time, cnt); + + return 0; +} + static int __init find_bit_test(void) { unsigned long nbits = BITMAP_LEN / SPARSE; @@ -158,6 +173,7 @@ static int __init find_bit_test(void) get_random_bytes(bitmap, sizeof(bitmap)); get_random_bytes(bitmap2, sizeof(bitmap2)); + test_bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN); test_find_next_bit(bitmap, BITMAP_LEN); test_find_next_zero_bit(bitmap, BITMAP_LEN); test_find_last_bit(bitmap, BITMAP_LEN); @@ -181,6 +197,7 @@ static int __init find_bit_test(void) __set_bit(get_random_u32_below(BITMAP_LEN), bitmap2); } + test_bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN); test_find_next_bit(bitmap, BITMAP_LEN); test_find_next_zero_bit(bitmap, BITMAP_LEN); test_find_last_bit(bitmap, BITMAP_LEN); |
