mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02: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 <andy@kernel.org> Suggested-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn> Acked-by: Andy Shevchenko <andy@kernel.org> Reviewed-by: Kees Cook <kees@kernel.org> Link: https://patch.msgid.link/20260130025018.172925-6-jiangfeng@kylinos.cn Signed-off-by: Paul Walmsley <pjw@kernel.org>
This commit is contained in:
parent
0020240a43
commit
e73bcb3708
|
|
@ -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),
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user