]> git.ipfire.org Git - thirdparty/git.git/commitdiff
read-cache: add simple performance test
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Sun, 9 Jun 2013 17:39:17 +0000 (19:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Jun 2013 00:03:00 +0000 (17:03 -0700)
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>
.gitignore
Makefile
t/perf/p0002-read-cache.sh [new file with mode: 0755]
test-read-cache.c [new file with mode: 0644]

index 6669bf0c6c9a0b42f74e2ed189350a6a9f11f17d..0a1f93b25a7b185a46bb235eb5a58e558aac24e1 100644 (file)
 /test-mktemp
 /test-parse-options
 /test-path-utils
+/test-read-cache
 /test-regex
 /test-revision-walking
 /test-run-command
index 0f931a203002aec397f8b454f93df9aee97a21ad..b0ee1649a44cee25e26da13491cb4398024171c1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh
new file mode 100755 (executable)
index 0000000..9180ae9
--- /dev/null
@@ -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
diff --git a/test-read-cache.c b/test-read-cache.c
new file mode 100644 (file)
index 0000000..b25bcf1
--- /dev/null
@@ -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;
+}