Skip to content

Instantly share code, notes, and snippets.

@tony-o
Created July 31, 2019 16:58
Show Gist options
  • Save tony-o/f3d9378eb0da16ca72299da5afe5e2d2 to your computer and use it in GitHub Desktop.
Save tony-o/f3d9378eb0da16ca72299da5afe5e2d2 to your computer and use it in GitHub Desktop.
λ ~$ perl6 -e 'use Bench;my @a = qw<abc cd e>; Bench.new.cmpthese(10000, { no-reverse => sub { @a.sort({ $^b.chars <=> $^a.chars }); }, reverse => sub { @a.sort(*.chars).reverse; } },);'
Benchmark:
Timing 10000 iterations of no-reverse, reverse...
no-reverse: 0.418 wallclock secs (0.377 usr 0.049 sys 0.427 cpu) @ 23939.825/s (n=10000)
reverse: 0.483 wallclock secs (0.447 usr 0.049 sys 0.495 cpu) @ 20700.334/s (n=10000)
O------------O---------O------------O---------O
| | Rate | no-reverse | reverse |
O============O=========O============O=========O
| no-reverse | 23940/s | -- | -33% |
| reverse | 20700/s | 49% | -- |
O------------O---------O------------O---------O
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment