Created
December 10, 2020 17:27
-
-
Save tony-o/22bb89f23c44bac271f2ac7a76da4721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
λ local:~$ raku -e 'use Bench; my @front = ^100; my @back = ^100; Bench.new.cmpthese(2_000_000, { pop => sub { @front.unshift(1); @front.pop() }, shift => sub { @back.push(1); @back.shift() }, });' | |
Benchmark: | |
Timing 2000000 iterations of pop, shift... | |
pop: 74.150 wallclock secs (66.918 usr 9.807 sys 76.724 cpu) @ 26972.511/s (n=2000000) | |
shift: 85.387 wallclock secs (77.559 usr 10.192 sys 87.750 cpu) @ 23422.720/s (n=2000000) | |
O-------O---------O------O-------O | |
| | Rate | pop | shift | | |
O=======O=========O======O=======O | |
| pop | 26973/s | -- | -55% | | |
| shift | 23423/s | 122% | -- | | |
O-------O---------O------O-------O |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment