Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. raku -e 'use Bench; my $b = Bench.new; my $header = "Content-Length-Whatever: 5"; $b.cmpthese(500000, {regex => sub { $header ~~ m:i{"Content-Length-Whatever"}; }, chomplc => sub { $header.chomp.lc eq "content-length-whatever" }, lcregex => sub { $header.lc ~~ m{"content-length-whatever"}; } });'
  2. Benchmark:
  3. Timing 500000 iterations of chomplc, lcregex, regex...
  4. chomplc: 4.693 wallclock secs (4.032 usr 0.745 sys 4.776 cpu) @ 106545.676/s (n=500000)
  5. lcregex: 6.508 wallclock secs (5.807 usr 0.743 sys 6.550 cpu) @ 76823.230/s (n=500000)
  6. regex: 7.949 wallclock secs (7.216 usr 0.772 sys 7.987 cpu) @ 62904.895/s (n=500000)
  7. O---------O----------O---------O---------O-------O
  8. | | Rate | chomplc | lcregex | regex |
  9. O=========O==========O=========O=========O=======O
  10. | chomplc | 106546/s | -- | -91% | -95% |
  11. | lcregex | 76823/s | 993% | -- | -42% |
  12. | regex | 62905/s | 1781% | 72% | -- |
  13. O---------O----------O---------O---------O-------O
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement