Skip to content

perf: eliminate 12s of sleep from dir_mtime.t#379

Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/perf-dir-mtime-test
Draft

perf: eliminate 12s of sleep from dir_mtime.t#379
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/perf-dir-mtime-test

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

What

Replace 12 sleep(1) calls with mock timestamp backdating in t/dir_mtime.t.

Why

Each subtest called sleep(1) to ensure mtime changes were detectable with
second-level time() granularity. With 12 calls, the test added ~12 seconds of
pure wall-clock delay to every CI run — more than any other test file.

How

New backdate_mock($mock) helper sets atime/mtime/ctime to time()-100 on the
mock directory object before each operation. The module updates timestamps to
time() during the operation, so the before/after comparison is trivially
detectable 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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant