From: Muhammed Dilshad A Date: Fri, 09 Oct 2026 15:08:50 GMT Subject: [PATCH v3 4/4] t: retire the sorting benchmark and mergesort helper Message-ID: In-Reply-To: p0071 was added to compare sorting implementations during mergesort development. Retire that benchmark. A benchmark can be added again if future sorting changes need measurements. With the numeric tests now in Clar, p0071 is the last user of test-tool mergesort. Remove the helper and its command and build registrations. Suggested-by: Patrick Steinhardt Signed-off-by: Muhammed Dilshad A --- Makefile | 1 - t/helper/meson.build | 1 - t/helper/test-mergesort.c | 65 --------------------------------------- t/helper/test-tool.c | 1 - t/helper/test-tool.h | 1 - t/meson.build | 1 - t/perf/p0071-sort.sh | 52 ------------------------------- 7 files changed, 122 deletions(-) delete mode 100644 t/helper/test-mergesort.c delete mode 100755 t/perf/p0071-sort.sh diff --git a/Makefile b/Makefile index cac535ba19..4b35808b2e 100644 --- a/Makefile +++ b/Makefile @@ -835,7 +835,6 @@ TEST_BUILTINS_OBJS += test-hexdump.o TEST_BUILTINS_OBJS += test-json-writer.o TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o TEST_BUILTINS_OBJS += test-match-trees.o -TEST_BUILTINS_OBJS += test-mergesort.o TEST_BUILTINS_OBJS += test-mktemp.o TEST_BUILTINS_OBJS += test-name-hash.o TEST_BUILTINS_OBJS += test-online-cpus.o diff --git a/t/helper/meson.build b/t/helper/meson.build index 3235f10ab8..e94e6f10fb 100644 --- a/t/helper/meson.build +++ b/t/helper/meson.build @@ -32,7 +32,6 @@ test_tool_sources = [ 'test-json-writer.c', 'test-lazy-init-name-hash.c', 'test-match-trees.c', - 'test-mergesort.c', 'test-mktemp.c', 'test-name-hash.c', 'test-online-cpus.c', diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c deleted file mode 100644 index d22a139f9e..0000000000 --- a/t/helper/test-mergesort.c +++ /dev/null @@ -1,65 +0,0 @@ -#include "test-tool.h" -#include "mem-pool.h" -#include "mergesort.h" -#include "strbuf.h" - -struct line { - char *text; - struct line *next; -}; - -DEFINE_LIST_SORT(static, sort_lines, struct line, next); - -static int compare_strings(const struct line *x, const struct line *y) -{ - return strcmp(x->text, y->text); -} - -static int sort_stdin(void) -{ - struct line *lines; - struct line **tail = &lines; - struct strbuf sb = STRBUF_INIT; - struct mem_pool lines_pool; - char *p; - - strbuf_read(&sb, 0, 0); - - /* - * Split by newline, but don't create an item - * for the empty string after the last separator. - */ - if (sb.len && sb.buf[sb.len - 1] == '\n') - strbuf_setlen(&sb, sb.len - 1); - - mem_pool_init(&lines_pool, 0); - p = sb.buf; - for (;;) { - char *eol = strchr(p, '\n'); - struct line *line = mem_pool_alloc(&lines_pool, sizeof(*line)); - line->text = p; - *tail = line; - tail = &line->next; - if (!eol) - break; - *eol = '\0'; - p = eol + 1; - } - *tail = NULL; - - sort_lines(&lines, compare_strings); - - while (lines) { - puts(lines->text); - lines = lines->next; - } - return 0; -} - -int cmd__mergesort(int argc, const char **argv) -{ - if (argc == 2 && !strcmp(argv[1], "sort")) - return sort_stdin(); - fprintf(stderr, "usage: test-tool mergesort sort\n"); - return 129; -} diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index b71a22b43b..2e80dc7ab8 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -42,7 +42,6 @@ static struct test_cmd cmds[] = { { "json-writer", cmd__json_writer }, { "lazy-init-name-hash", cmd__lazy_init_name_hash }, { "match-trees", cmd__match_trees }, - { "mergesort", cmd__mergesort }, { "mktemp", cmd__mktemp }, { "name-hash", cmd__name_hash }, { "online-cpus", cmd__online_cpus }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index f2885b33d5..9442c61ffd 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -35,7 +35,6 @@ int cmd__hexdump(int argc, const char **argv); int cmd__json_writer(int argc, const char **argv); int cmd__lazy_init_name_hash(int argc, const char **argv); int cmd__match_trees(int argc, const char **argv); -int cmd__mergesort(int argc, const char **argv); int cmd__mktemp(int argc, const char **argv); int cmd__name_hash(int argc, const char **argv); int cmd__online_cpus(int argc, const char **argv); diff --git a/t/meson.build b/t/meson.build index 2752321e0d..07436b63f4 100644 --- a/t/meson.build +++ b/t/meson.build @@ -1146,7 +1146,6 @@ benchmarks = [ 'perf/p0006-read-tree-checkout.sh', 'perf/p0007-write-cache.sh', 'perf/p0008-odb-fsync.sh', - 'perf/p0071-sort.sh', 'perf/p0090-cache-tree.sh', 'perf/p0100-globbing.sh', 'perf/p1006-cat-file.sh', diff --git a/t/perf/p0071-sort.sh b/t/perf/p0071-sort.sh deleted file mode 100755 index ae4ddac864..0000000000 --- a/t/perf/p0071-sort.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -test_description='Basic sort performance tests' -. ./perf-lib.sh - -test_perf_default_repo - -test_expect_success 'setup' ' - git ls-files --stage "*.[ch]" "*.sh" | - cut -f2 -d" " | - git cat-file --batch >unsorted -' - -test_perf 'sort(1) unsorted' ' - sort sorted -' - -test_expect_success 'reverse' ' - sort -r reversed -' - -for file in sorted reversed -do - test_perf "sort(1) $file" " - sort <$file >actual - " -done - -for file in unsorted sorted reversed -do - - test_perf "string_list_sort() $file" " - test-tool string-list sort <$file >actual - " - - test_expect_success "string_list_sort() $file sorts like sort(1)" " - test_cmp_bin sorted actual - " -done - -for file in unsorted sorted reversed -do - test_perf "DEFINE_LIST_SORT $file" " - test-tool mergesort sort <$file >actual - " - - test_expect_success "DEFINE_LIST_SORT $file sorts like sort(1)" " - test_cmp_bin sorted actual - " -done - -test_done -- 2.55.0