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>

Nipunn Koorapati committed Oct 20, 2020 at 13:41 UTC 471b1157451ef06d7cfe092c07a87e93142a8dc4
1 file changed +37 -99
t/perf/p7519-fsmonitor.sh
+37 -99
@@ -125,61 +125,53 @@ test_expect_success "setup for fsmonitor" '
125 git status # Warm caches
126 '
127
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
132
132 -test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
133 - git status
134 -'
133 + test_perf "$@"
134 +}
135
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 + '
140
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 + '
144
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 + '
148
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 + '
152
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 + '
156
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 + '
160
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 + '
164
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 + '
168
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 +}
173
180 -test_perf "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
181 - git diff -- 10000_files
182 -'
174 +test_fsmonitor_suite
175
176 test_expect_success "setup without fsmonitor" '
177 unset INTEGRATION_SCRIPT &&
@@ -187,61 +179,7 @@ test_expect_success "setup without fsmonitor" '
179 git update-index --no-fsmonitor
180 '
181
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
183
184 if test_have_prereq WATCHMAN
185 then