perf: eliminate 12s of sleep from dir_mtime.t#379
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
perf: eliminate 12s of sleep from dir_mtime.t#379Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
Replace sleep-based timestamp detection with mock timestamp backdating. Each subtest was calling sleep(1) to ensure mtime changes were detectable with second-level granularity — 12 calls total, adding ~12s of wall time. Instead, backdate the mock directory's atime/mtime/ctime to time()-100 before each operation. The operation updates timestamps to time(), making the before/after comparison trivially detectable without any delay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace 12
sleep(1)calls with mock timestamp backdating int/dir_mtime.t.Why
Each subtest called
sleep(1)to ensure mtime changes were detectable withsecond-level
time()granularity. With 12 calls, the test added ~12 seconds ofpure wall-clock delay to every CI run — more than any other test file.
How
New
backdate_mock($mock)helper sets atime/mtime/ctime totime()-100on themock directory object before each operation. The module updates timestamps to
time()during the operation, so the before/after comparison is triviallydetectable without any sleep. This follows the same pattern used in
t/creation_timestamps.t.Testing
Same test logic, same assertions, same coverage — just faster (12s → <0.1s).
🤖 Generated with Claude Code