perf: add test for writing the index

A performance test for writing the index to be able to determine if changes to allocating ondisk structure help. Signed-off-by: Kevin Willford <kewillf@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kevin Willford committed Aug 21, 2017 at 15:24 UTC 3921a0b3c3441d189f838656b30fbafa25e9eec4
3 files changed +53
Makefile
+1
@@ -655,6 +655,7 @@ TEST_PROGRAMS_NEED_X += test-parse-options
655 TEST_PROGRAMS_NEED_X += test-path-utils
656 TEST_PROGRAMS_NEED_X += test-prio-queue
657 TEST_PROGRAMS_NEED_X += test-read-cache
658 +TEST_PROGRAMS_NEED_X += test-write-cache
659 TEST_PROGRAMS_NEED_X += test-ref-store
660 TEST_PROGRAMS_NEED_X += test-regex
661 TEST_PROGRAMS_NEED_X += test-revision-walking
t/helper/test-write-cache.c new
+23
@@ -0,0 +1,23 @@
1 +#include "cache.h"
2 +#include "lockfile.h"
3 +
4 +static struct lock_file index_lock;
5 +
6 +int cmd_main(int argc, const char **argv)
7 +{
8 + int i, cnt = 1, lockfd;
9 + if (argc == 2)
10 + cnt = strtol(argv[1], NULL, 0);
11 + setup_git_directory();
12 + read_cache();
13 + for (i = 0; i < cnt; i++) {
14 + lockfd = hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
15 + if (0 <= lockfd) {
16 + write_locked_index(&the_index, &index_lock, COMMIT_LOCK);
17 + } else {
18 + rollback_lock_file(&index_lock);
19 + }
20 + }
21 +
22 + return 0;
23 +}
t/perf/p0007-write-cache.sh new
+29
@@ -0,0 +1,29 @@
1 +#!/bin/sh
2 +
3 +test_description="Tests performance of writing the index"
4 +
5 +. ./perf-lib.sh
6 +
7 +test_perf_default_repo
8 +
9 +test_expect_success "setup repo" '
10 + if git rev-parse --verify refs/heads/p0006-ballast^{commit}
11 + then
12 + echo Assuming synthetic repo from many-files.sh
13 + git config --local core.sparsecheckout 1
14 + cat >.git/info/sparse-checkout <<-EOF
15 + /*
16 + !ballast/*
17 + EOF
18 + else
19 + echo Assuming non-synthetic repo...
20 + fi &&
21 + nr_files=$(git ls-files | wc -l)
22 +'
23 +
24 +count=3
25 +test_perf "write_locked_index $count times ($nr_files files)" "
26 + test-write-cache $count
27 +"
28 +
29 +test_done