diff options
Diffstat (limited to 'lib/find_bit_benchmark.c')
| -rw-r--r-- | lib/find_bit_benchmark.c | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c index db904b57d4b8..10754586403b 100644 --- a/lib/find_bit_benchmark.c +++ b/lib/find_bit_benchmark.c @@ -115,6 +115,22 @@ static int __init test_find_last_bit(const void *bitmap, unsigned long len)  	return 0;  } +static int __init test_find_nth_bit(const unsigned long *bitmap, unsigned long len) +{ +	unsigned long l, n, w = bitmap_weight(bitmap, len); +	ktime_t time; + +	time = ktime_get(); +	for (n = 0; n < w; n++) { +		l = find_nth_bit(bitmap, len, n); +		WARN_ON(l >= len); +	} +	time = ktime_get() - time; +	pr_err("find_nth_bit:       %18llu ns, %6ld iterations\n", time, w); + +	return 0; +} +  static int __init test_find_next_and_bit(const void *bitmap,  		const void *bitmap2, unsigned long len)  { @@ -142,6 +158,7 @@ static int __init find_bit_test(void)  	test_find_next_bit(bitmap, BITMAP_LEN);  	test_find_next_zero_bit(bitmap, BITMAP_LEN);  	test_find_last_bit(bitmap, BITMAP_LEN); +	test_find_nth_bit(bitmap, BITMAP_LEN / 10);  	/*  	 * test_find_first_bit() may take some time, so @@ -164,6 +181,7 @@ static int __init find_bit_test(void)  	test_find_next_bit(bitmap, BITMAP_LEN);  	test_find_next_zero_bit(bitmap, BITMAP_LEN);  	test_find_last_bit(bitmap, BITMAP_LEN); +	test_find_nth_bit(bitmap, BITMAP_LEN);  	test_find_first_bit(bitmap, BITMAP_LEN);  	test_find_first_and_bit(bitmap, bitmap2, BITMAP_LEN);  	test_find_next_and_bit(bitmap, bitmap2, BITMAP_LEN); | 
