mvdan / xurls

Extract urls from text
BSD 3-Clause "New" or "Revised" License
1.19k stars 116 forks source link

optimize regular expressions #60

Closed gibson042 closed 2 years ago

gibson042 commented 2 years ago

benchstat vs. master@588e8594267cca0d170ceda20342f7a883b80153:

name             old time/op    new time/op    delta
StrictEmpty-4      15.0ns ± 1%    14.9ns ± 1%   -0.51%  (p=0.004 n=7+10)
StrictSingle-4     41.2µs ± 4%    34.2µs ± 2%  -17.08%  (p=0.000 n=10+10)
StrictMany-4        125µs ± 1%     105µs ± 2%  -15.80%  (p=0.000 n=10+10)
RelaxedEmpty-4     15.2µs ± 3%     9.9µs ± 1%  -35.01%  (p=0.000 n=10+10)
RelaxedSingle-4    95.3µs ± 5%    57.8µs ± 1%  -39.29%  (p=0.000 n=10+10)
RelaxedMany-4       247µs ± 1%     156µs ± 2%  -36.71%  (p=0.000 n=9+10)

name             old alloc/op   new alloc/op   delta
StrictEmpty-4       0.00B          0.00B          ~     (all equal)
StrictSingle-4       364B ± 4%      187B ±15%  -48.58%  (p=0.000 n=9+10)
StrictMany-4         792B ± 6%      241B ±14%  -69.59%  (p=0.000 n=10+10)
RelaxedEmpty-4      73.8B ± 2%     1.5B ±233%  -97.97%  (p=0.000 n=10+10)
RelaxedSingle-4    2.43kB ± 4%    0.34kB ±13%  -86.02%  (p=0.000 n=9+10)
RelaxedMany-4      5.02kB ± 3%    0.54kB ±22%  -89.18%  (p=0.000 n=10+10)

name             old allocs/op  new allocs/op  delta
StrictEmpty-4        0.00           0.00          ~     (all equal)
StrictSingle-4       2.00 ± 0%      2.00 ± 0%     ~     (all equal)
StrictMany-4         4.00 ± 0%      4.00 ± 0%     ~     (all equal)
RelaxedEmpty-4       0.00           0.00          ~     (all equal)
RelaxedSingle-4      4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.000 n=10+10)
RelaxedMany-4        8.00 ± 0%      5.00 ± 0%  -37.50%  (p=0.002 n=8+10)
mvdan commented 2 years ago

I'll send a follow-up PR shortly; FYI in case that could cause conflicts.