mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
lib/string_kunit: extend benchmarks to strnlen() and chr searches
Extend the string benchmarking suite to include strnlen(), strchr(), and strrchr(). For character search functions strchr() and strrchr(), the benchmark targets the NUL character. This ensures the entire string is scanned, providing a consistent measure of full-length processing efficiency comparable to strlen(). Suggested-by: Andy Shevchenko <[email protected]> Suggested-by: Eric Biggers <[email protected]> Signed-off-by: Feng Jiang <[email protected]> Acked-by: Andy Shevchenko <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paul Walmsley <[email protected]>
This commit is contained in:
1 parent
0020240a43
commit
e73bcb3708
1 file changed
+18
@@ -866,6 +866,21 @@ static void string_bench_strlen(struct kunit *test)
|
||||
STRING_BENCH_BUF(test, buf, len, strlen, buf);
|
||||
}
|
||||
|
||||
static void string_bench_strnlen(struct kunit *test)
|
||||
{
|
||||
STRING_BENCH_BUF(test, buf, len, strnlen, buf, len);
|
||||
}
|
||||
|
||||
static void string_bench_strchr(struct kunit *test)
|
||||
{
|
||||
STRING_BENCH_BUF(test, buf, len, strchr, buf, '\0');
|
||||
}
|
||||
|
||||
static void string_bench_strrchr(struct kunit *test)
|
||||
{
|
||||
STRING_BENCH_BUF(test, buf, len, strrchr, buf, '\0');
|
||||
}
|
||||
|
||||
static struct kunit_case string_test_cases[] = {
|
||||
KUNIT_CASE(string_test_memset16),
|
||||
KUNIT_CASE(string_test_memset32),
|
||||
@@ -892,6 +907,9 @@ static struct kunit_case string_test_cases[] = {
|
||||
KUNIT_CASE(string_test_memtostr),
|
||||
KUNIT_CASE(string_test_strends),
|
||||
KUNIT_CASE(string_bench_strlen),
|
||||
KUNIT_CASE(string_bench_strnlen),
|
||||
KUNIT_CASE(string_bench_strchr),
|
||||
KUNIT_CASE(string_bench_strrchr),
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user