Re: [PATCH 1/2] t4205: compare huge output without diff
From: Jeff King <hidden>
Date: 2026-09-25 00:13:34
On Thu, Sep 24, 2026 at 04:41:05PM -0400, Tamir Duberstein wrote:
quoted
It would be great to back up the claim that test_cmp_bin is better than test_cmp, e.g. by comparing peak RSS and its runtime.As for the comparison: on Linux arm64 with GNU diffutils 3.8 using two identical files containing 2,147,483,649 "1" bytes followed by "0\n" (matching this test's expected output) gave: Command Mean +/- stddev Maximum RSS (KiB) diff -u expect actual 5.276 +/- 0.572 s 4199924 cmp expect actual 0.506 +/- 0.099 s 1264
Yeah, that's a big difference. This is probably an outlier because of the giant files, but I've wondered if test_cmp() ought to be doing something like: # first check quickly if there is any difference cmp "$@" && return 0 # if not, then we can spend time to produce a useful output diff "$@" But I never pursued it because I figured most of the things we compare are not big enough to matter (and really the comparison itself is dwarfed by the process startup time). So I am happy just marking this particular case as cmp_bin, too. -Peff