Commit 639b52b
committed
Check deadline less frequently
Calling time.Now() is a bit expensive to do in a tight loop.
Check it only every 16th time.
This results in an average 0.16% time overrun when the deadline is hit,
which seems a small price to pay for up to a 25% speedup on the
actual work.
name old time/op new time/op delta
DiffHalfMatch-8 108µs ± 1% 108µs ± 0% ~ (p=0.211 n=10+9)
DiffCleanupSemantic-8 973µs ± 0% 971µs ± 1% ~ (p=0.673 n=8+9)
DiffMain-8 1.01s ± 0% 1.01s ± 0% +0.16% (p=0.003 n=9+10)
DiffMainLarge-8 110ms ± 1% 102ms ± 3% -7.44% (p=0.000 n=8+10)
DiffMainRunesLargeLines-8 693µs ± 1% 515µs ± 1% -25.70% (p=0.000 n=8+9)
name old alloc/op new alloc/op delta
DiffHalfMatch-8 106kB ± 0% 106kB ± 0% ~ (all equal)
DiffCleanupSemantic-8 177kB ± 0% 177kB ± 0% ~ (all equal)
DiffMain-8 16.4MB ± 0% 16.4MB ± 0% ~ (all equal)
DiffMainLarge-8 4.81MB ± 0% 4.81MB ± 0% ~ (p=0.764 n=10+9)
DiffMainRunesLargeLines-8 174kB ± 0% 174kB ± 0% +0.01% (p=0.014 n=10+10)
name old allocs/op new allocs/op delta
DiffHalfMatch-8 2.00 ± 0% 2.00 ± 0% ~ (all equal)
DiffCleanupSemantic-8 3.12k ± 0% 3.12k ± 0% ~ (all equal)
DiffMain-8 83.0 ± 0% 83.0 ± 0% ~ (all equal)
DiffMainLarge-8 46.3k ± 0% 46.3k ± 0% ~ (p=1.000 n=10+10)
DiffMainRunesLargeLines-8 1.08k ± 0% 1.08k ± 0% ~ (p=0.211 n=10+10)1 parent 258a5e0 commit 639b52b
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| |||
0 commit comments