summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-30 02:16:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-30 02:16:41 (GMT)
commit140921ca21f7ac35af07755e35205d6065b434be (patch)
treee41ecb20e3b118015aedf284dbbc6825dbdd8364
parent3c5a78280fa5535050fe83b51cafb9ca51e8d9e8 (diff)
parent62ca75a6b9cb2e51b4eed7c551f13975b440a86c (diff)
downloadgit-140921ca21f7ac35af07755e35205d6065b434be.zip
git-140921ca21f7ac35af07755e35205d6065b434be.tar.gz
git-140921ca21f7ac35af07755e35205d6065b434be.tar.bz2
Merge branch 'ab/perf-wildmatch'
Add perf-test for wildmatch. * ab/perf-wildmatch: perf: add test showing exponential growth in path globbing perf: add function to setup a fresh test repo
-rw-r--r--t/perf/README1
-rwxr-xr-xt/perf/p0100-globbing.sh43
-rw-r--r--t/perf/perf-lib.sh19
3 files changed, 59 insertions, 4 deletions
diff --git a/t/perf/README b/t/perf/README
index 49ea434..de2fe15 100644
--- a/t/perf/README
+++ b/t/perf/README
@@ -106,6 +106,7 @@ sources perf-lib.sh:
After that you will want to use some of the following:
+ test_perf_fresh_repo # sets up an empty repository
test_perf_default_repo # sets up a "normal" repository
test_perf_large_repo # sets up a "large" repository
diff --git a/t/perf/p0100-globbing.sh b/t/perf/p0100-globbing.sh
new file mode 100755
index 0000000..dd18a9c
--- /dev/null
+++ b/t/perf/p0100-globbing.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description="Tests pathological globbing performance
+
+Shows how Git's globbing performance performs when given the sort of
+pathological patterns described in at https://research.swtch.com/glob
+"
+
+. ./perf-lib.sh
+
+test_globs_big='10 25 50 75 100'
+test_globs_small='1 2 3 4 5 6'
+
+test_perf_fresh_repo
+
+test_expect_success 'setup' '
+ for i in $(test_seq 1 100)
+ do
+ printf "a" >>refname &&
+ for j in $(test_seq 1 $i)
+ do
+ printf "a*" >>refglob.$i
+ done &&
+ echo b >>refglob.$i
+ done &&
+ test_commit test $(cat refname).t "" $(cat refname).t
+'
+
+for i in $test_globs_small
+do
+ test_perf "refglob((a*)^nb) against tag (a^100).t; n = $i" '
+ git for-each-ref "refs/tags/$(cat refglob.'$i')b"
+ '
+done
+
+for i in $test_globs_small
+do
+ test_perf "fileglob((a*)^nb) against file (a^100).t; n = $i" '
+ git ls-files "$(cat refglob.'$i')b"
+ '
+done
+
+test_done
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index ab4b8b0..b6fc880 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -78,6 +78,10 @@ if test -z "$GIT_PERF_LARGE_REPO"; then
GIT_PERF_LARGE_REPO=$TEST_DIRECTORY/..
fi
+test_perf_do_repo_symlink_config_ () {
+ test_have_prereq SYMLINKS || git config core.symlinks false
+}
+
test_perf_create_repo_from () {
test "$#" = 2 ||
error "bug in the test script: not 2 parameters to test-create-repo"
@@ -102,15 +106,22 @@ test_perf_create_repo_from () {
) &&
(
cd "$repo" &&
- "$MODERN_GIT" init -q && {
- test_have_prereq SYMLINKS ||
- git config core.symlinks false
- } &&
+ "$MODERN_GIT" init -q &&
+ test_perf_do_repo_symlink_config_ &&
mv .git/hooks .git/hooks-disabled 2>/dev/null
) || error "failed to copy repository '$source' to '$repo'"
}
# call at least one of these to establish an appropriately-sized repository
+test_perf_fresh_repo () {
+ repo="${1:-$TRASH_DIRECTORY}"
+ "$MODERN_GIT" init -q "$repo" &&
+ (
+ cd "$repo" &&
+ test_perf_do_repo_symlink_config_
+ )
+}
+
test_perf_default_repo () {
test_perf_create_repo_from "${1:-$TRASH_DIRECTORY}" "$GIT_PERF_REPO"
}