Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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"}; } });'
- Benchmark:
- Timing 500000 iterations of chomplc, lcregex, regex...
- chomplc: 4.693 wallclock secs (4.032 usr 0.745 sys 4.776 cpu) @ 106545.676/s (n=500000)
- lcregex: 6.508 wallclock secs (5.807 usr 0.743 sys 6.550 cpu) @ 76823.230/s (n=500000)
- regex: 7.949 wallclock secs (7.216 usr 0.772 sys 7.987 cpu) @ 62904.895/s (n=500000)
- O---------O----------O---------O---------O-------O
- | | Rate | chomplc | lcregex | regex |
- O=========O==========O=========O=========O=======O
- | chomplc | 106546/s | -- | -91% | -95% |
- | lcregex | 76823/s | 993% | -- | -42% |
- | regex | 62905/s | 1781% | 72% | -- |
- O---------O----------O---------O---------O-------O
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement