summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipunn Koorapati <nipunn@dropbox.com>2020-10-20 13:41:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-20 19:52:23 (GMT)
commit471b1157451ef06d7cfe092c07a87e93142a8dc4 (patch)
tree9e312326ca6eb24a1f25f9fa851111ac699dd8f2
parented5a24573d8caf222dbb81a46dc97a4459928e2d (diff)
downloadgit-471b1157451ef06d7cfe092c07a87e93142a8dc4.zip
git-471b1157451ef06d7cfe092c07a87e93142a8dc4.tar.gz
git-471b1157451ef06d7cfe092c07a87e93142a8dc4.tar.bz2
p7519-fsmonitor: refactor to avoid code duplication
Much of the benchmark code is redundant. This is easier to understand and edit. Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/perf/p7519-fsmonitor.sh136
1 files changed, 37 insertions, 99 deletions
diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh
index ef4c3c8..75a0cef 100755
--- a/t/perf/p7519-fsmonitor.sh
+++ b/t/perf/p7519-fsmonitor.sh
@@ -125,61 +125,53 @@ test_expect_success "setup for fsmonitor" '
git status # Warm caches
'
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+test_perf_w_drop_caches () {
+ if test -n "$GIT_PERF_7519_DROP_CACHE"; then
+ test-tool drop-caches
+ fi
-test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status
-'
+ test_perf "$@"
+}
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+test_fsmonitor_suite() {
+ test_perf_w_drop_caches "status (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git status
+ '
-test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uno
-'
+ test_perf_w_drop_caches "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git status -uno
+ '
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+ test_perf_w_drop_caches "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git status -uall
+ '
-test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uall
-'
-
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
-
-test_perf "diff (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff
-'
+ test_perf_w_drop_caches "diff (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git diff
+ '
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+ test_perf_w_drop_caches "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git diff -- 1_file
+ '
-test_perf "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 1_file
-'
+ test_perf_w_drop_caches "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git diff -- 10_files
+ '
-test_perf "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 10_files
-'
+ test_perf_w_drop_caches "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git diff -- 100_files
+ '
-test_perf "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 100_files
-'
+ test_perf_w_drop_caches "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git diff -- 1000_files
+ '
-test_perf "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 1000_files
-'
+ test_perf_w_drop_caches "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
+ git diff -- 10000_files
+ '
+}
-test_perf "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 10000_files
-'
+test_fsmonitor_suite
test_expect_success "setup without fsmonitor" '
unset INTEGRATION_SCRIPT &&
@@ -187,61 +179,7 @@ test_expect_success "setup without fsmonitor" '
git update-index --no-fsmonitor
'
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
-
-test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status
-'
-
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
-
-test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uno
-'
-
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
-
-test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uall
-'
-
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
-
-test_perf "diff (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff
-'
-
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
-
-test_perf "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 1_file
-'
-
-test_perf "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 10_files
-'
-
-test_perf "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 100_files
-'
-
-test_perf "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 1000_files
-'
-
-test_perf "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
- git diff -- 10000_files
-'
+test_fsmonitor_suite
if test_have_prereq WATCHMAN
then