linux/lib/find_bit_benchmark.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Test for find_*_bit functions.
 *
 * Copyright (c) 2017 Cavium.
 */

/*
 * find_bit functions are widely used in kernel, so the successful boot
 * is good enough test for correctness.
 *
 * This test is focused on performance of traversing bitmaps. Two typical
 * scenarios are reproduced:
 * - randomly filled bitmap with approximately equal number of set and
 *   cleared bits;
 * - sparse bitmap with few set bits at random positions.
 */

#include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/printk.h>
#include <linux/random.h>

#define BITMAP_LEN
#define SPARSE

static DECLARE_BITMAP(bitmap, BITMAP_LEN) __initdata;
static DECLARE_BITMAP(bitmap2, BITMAP_LEN) __initdata;

/*
 * This is Schlemiel the Painter's algorithm. It should be called after
 * all other tests for the same bitmap because it sets all bits of bitmap to 1.
 */
static int __init test_find_first_bit(void *bitmap, unsigned long len)
{}

static int __init test_find_first_and_bit(void *bitmap, const void *bitmap2, unsigned long len)
{}

static int __init test_find_next_bit(const void *bitmap, unsigned long len)
{}

static int __init test_find_next_zero_bit(const void *bitmap, unsigned long len)
{}

static int __init test_find_last_bit(const void *bitmap, unsigned long len)
{}

static int __init test_find_nth_bit(const unsigned long *bitmap, unsigned long len)
{}

static int __init test_find_next_and_bit(const void *bitmap,
		const void *bitmap2, unsigned long len)
{}

static int __init find_bit_test(void)
{}
module_init();

MODULE_DESCRIPTION();
MODULE_LICENSE();