Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2013-06-09 21:39:17 +0400
committerJunio C Hamano <gitster@pobox.com>2013-06-10 04:03:00 +0400
commit1ecb5ff141f6e54727c746446b52af51016e662c (patch)
treee2b77c617509a40cc37941d3a3bbb8821b65aba1
parentedca4152560522a431a51fc0a06147fc680b5b18 (diff)
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>
-rw-r--r--.gitignore1
-rw-r--r--Makefile1
-rwxr-xr-xt/perf/p0002-read-cache.sh14
-rw-r--r--test-read-cache.c13
4 files changed, 29 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 6669bf0c6c..0a1f93b25a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -190,6 +190,7 @@
/test-mktemp
/test-parse-options
/test-path-utils
+/test-read-cache
/test-regex
/test-revision-walking
/test-run-command
diff --git a/Makefile b/Makefile
index 0f931a2030..b0ee1649a4 100644
--- 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
index 0000000000..9180ae9343
--- /dev/null
+++ b/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
diff --git a/test-read-cache.c b/test-read-cache.c
new file mode 100644
index 0000000000..b25bcf139b
--- /dev/null
+++ b/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;
+}