mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-24 04:15:07 -05:00
bcachefs: eytzinger0_find_test improvement
In eytzinger0_find_test(), remember the smallest element seen so far instead of comparing adjacent array elements. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
committed by
Kent Overstreet
parent
ec70103f9b
commit
e8a0966ffa
@@ -808,15 +808,18 @@ void eytzinger0_find_test(void)
|
||||
u16 *test_array = kmalloc_array(allocated, sizeof(test_array[0]), GFP_KERNEL);
|
||||
|
||||
for (nr = 1; nr < allocated; nr++) {
|
||||
u16 prev = 0;
|
||||
|
||||
pr_info("testing %u elems\n", nr);
|
||||
|
||||
get_random_bytes(test_array, nr * sizeof(test_array[0]));
|
||||
eytzinger0_sort(test_array, nr, sizeof(test_array[0]), cmp_u16, NULL);
|
||||
|
||||
/* verify array is sorted correctly: */
|
||||
eytzinger0_for_each(j, nr)
|
||||
BUG_ON(j != eytzinger0_last(nr) &&
|
||||
test_array[j] > test_array[eytzinger0_next(j, nr)]);
|
||||
eytzinger0_for_each(j, nr) {
|
||||
BUG_ON(test_array[j] < prev);
|
||||
prev = test_array[j];
|
||||
}
|
||||
|
||||
for (i = 0; i < U16_MAX; i += 1 << 12)
|
||||
eytzinger0_find_test_val(test_array, nr, i);
|
||||
|
||||
Reference in New Issue
Block a user