Add a perf test for the refresh_index() function to compliment the existing read()/discard() in a loop perf test added in 1ecb5ff141f (read-cache: add simple performance test, 2013-06-09). Since this test is much slower (around 10x) than the previous read()/discard() test let's run it 100 times instead of the 1000 time the first one runs. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- t/helper/test-read-cache-perf.c | 12 ++++++++++++ t/perf/p0002-read-cache.sh | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/t/helper/test-read-cache-perf.c b/t/helper/test-read-cache-perf.c index 54ad0c3135..a2802559a5 100644 --- a/t/helper/test-read-cache-perf.c +++ b/t/helper/test-read-cache-perf.c @@ -11,8 +11,11 @@ int cmd__read_cache_perf(int argc, const char **argv) { struct repository *r = the_repository; int cnt = -1; + int refresh = 0; struct option options[] = { OPT_INTEGER(0, "count", &cnt, "number of passes"), + OPT_BOOL(0, "refresh", &refresh, + "call refresh_index() in a loop, not read()/discard()"), OPT_END() }; @@ -26,10 +29,19 @@ int cmd__read_cache_perf(int argc, const char **argv) options); setup_git_directory(); + if (refresh) + repo_read_index(r); while (cnt--) { + if (refresh) { + unsigned int flags = REFRESH_QUIET|REFRESH_PROGRESS; + refresh_index(r->index, flags, NULL, NULL, NULL); + continue; + } repo_read_index(r); discard_index(r->index); } + if (refresh) + discard_index(r->index); return 0; } diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh index 1762b64865..cbccc5ace9 100755 --- a/t/perf/p0002-read-cache.sh +++ b/t/perf/p0002-read-cache.sh @@ -11,4 +11,9 @@ test_perf "read_cache/discard_cache $count times" " test-tool read-cache-perf --count=$count " +count=100 +test_perf "refresh_index() $count times" " + test-tool read-cache-perf --count=$count --refresh +" + test_done -- 2.32.0.rc3.434.gd8aed1f08a7