@@ -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;
}
@@ -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
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@gmail.com> --- t/helper/test-read-cache-perf.c | 12 ++++++++++++ t/perf/p0002-read-cache.sh | 5 +++++ 2 files changed, 17 insertions(+)