Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
read-cache: add simple performance test
Add the helper test-read-cache, which can be used to call read_cache and
discard_cache in a loop as well as a performance check based on it.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Jun 10, 2013
1 parent edca415 commit 1ecb5ff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -190,6 +190,7 @@
/test-mktemp
/test-parse-options
/test-path-utils
/test-read-cache
/test-regex
/test-revision-walking
/test-run-command
Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -558,6 +558,7 @@ TEST_PROGRAMS_NEED_X += test-mergesort
TEST_PROGRAMS_NEED_X += test-mktemp
TEST_PROGRAMS_NEED_X += test-parse-options
TEST_PROGRAMS_NEED_X += test-path-utils
TEST_PROGRAMS_NEED_X += test-read-cache
TEST_PROGRAMS_NEED_X += test-regex
TEST_PROGRAMS_NEED_X += test-revision-walking
TEST_PROGRAMS_NEED_X += test-run-command
Expand Down
14 changes: 14 additions & 0 deletions t/perf/p0002-read-cache.sh
@@ -0,0 +1,14 @@
#!/bin/sh

test_description="Tests performance of reading the index"

. ./perf-lib.sh

test_perf_default_repo

count=1000
test_perf "read_cache/discard_cache $count times" "
test-read-cache $count
"

test_done
13 changes: 13 additions & 0 deletions test-read-cache.c
@@ -0,0 +1,13 @@
#include "cache.h"

int main (int argc, char **argv)
{
int i, cnt = 1;
if (argc == 2)
cnt = strtol(argv[1], NULL, 0);
for (i = 0; i < cnt; i++) {
read_cache();
discard_cache();
}
return 0;
}

0 comments on commit 1ecb5ff

Please sign in to comment.