Skip to content

Commit 471b115

Browse files
nipunn1313gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed5a245 commit 471b115

File tree

1 file changed

+37
-99
lines changed

1 file changed

+37
-99
lines changed

t/perf/p7519-fsmonitor.sh

Lines changed: 37 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -125,123 +125,61 @@ test_expect_success "setup for fsmonitor" '
125125
git status # Warm caches
126126
'
127127

128-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
129-
test-tool drop-caches
130-
fi
128+
test_perf_w_drop_caches () {
129+
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
130+
test-tool drop-caches
131+
fi
131132

132-
test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
133-
git status
134-
'
133+
test_perf "$@"
134+
}
135135

136-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
137-
test-tool drop-caches
138-
fi
136+
test_fsmonitor_suite() {
137+
test_perf_w_drop_caches "status (fsmonitor=$INTEGRATION_SCRIPT)" '
138+
git status
139+
'
139140

140-
test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
141-
git status -uno
142-
'
141+
test_perf_w_drop_caches "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
142+
git status -uno
143+
'
143144

144-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
145-
test-tool drop-caches
146-
fi
145+
test_perf_w_drop_caches "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
146+
git status -uall
147+
'
147148

148-
test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
149-
git status -uall
150-
'
151-
152-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
153-
test-tool drop-caches
154-
fi
155-
156-
test_perf "diff (fsmonitor=$INTEGRATION_SCRIPT)" '
157-
git diff
158-
'
149+
test_perf_w_drop_caches "diff (fsmonitor=$INTEGRATION_SCRIPT)" '
150+
git diff
151+
'
159152

160-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
161-
test-tool drop-caches
162-
fi
153+
test_perf_w_drop_caches "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" '
154+
git diff -- 1_file
155+
'
163156

164-
test_perf "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" '
165-
git diff -- 1_file
166-
'
157+
test_perf_w_drop_caches "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" '
158+
git diff -- 10_files
159+
'
167160

168-
test_perf "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" '
169-
git diff -- 10_files
170-
'
161+
test_perf_w_drop_caches "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" '
162+
git diff -- 100_files
163+
'
171164

172-
test_perf "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" '
173-
git diff -- 100_files
174-
'
165+
test_perf_w_drop_caches "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
166+
git diff -- 1000_files
167+
'
175168

176-
test_perf "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
177-
git diff -- 1000_files
178-
'
169+
test_perf_w_drop_caches "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
170+
git diff -- 10000_files
171+
'
172+
}
179173

180-
test_perf "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
181-
git diff -- 10000_files
182-
'
174+
test_fsmonitor_suite
183175

184176
test_expect_success "setup without fsmonitor" '
185177
unset INTEGRATION_SCRIPT &&
186178
git config --unset core.fsmonitor &&
187179
git update-index --no-fsmonitor
188180
'
189181

190-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
191-
test-tool drop-caches
192-
fi
193-
194-
test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
195-
git status
196-
'
197-
198-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
199-
test-tool drop-caches
200-
fi
201-
202-
test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
203-
git status -uno
204-
'
205-
206-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
207-
test-tool drop-caches
208-
fi
209-
210-
test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
211-
git status -uall
212-
'
213-
214-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
215-
test-tool drop-caches
216-
fi
217-
218-
test_perf "diff (fsmonitor=$INTEGRATION_SCRIPT)" '
219-
git diff
220-
'
221-
222-
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
223-
test-tool drop-caches
224-
fi
225-
226-
test_perf "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" '
227-
git diff -- 1_file
228-
'
229-
230-
test_perf "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" '
231-
git diff -- 10_files
232-
'
233-
234-
test_perf "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" '
235-
git diff -- 100_files
236-
'
237-
238-
test_perf "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
239-
git diff -- 1000_files
240-
'
241-
242-
test_perf "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
243-
git diff -- 10000_files
244-
'
182+
test_fsmonitor_suite
245183

246184
if test_have_prereq WATCHMAN
247185
then

0 commit comments

Comments
 (0)