Created
January 10, 2019 16:54
-
-
Save cynovg/87dbb806051ba52894835c295e02e3b1 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use v5.26.0; | |
use List::Util qw/first any/; | |
use Benchmark qw(:all); | |
timethese(10000, { | |
'foreach' => sub { | |
foreach (1..1000) { | |
last if $_ == 1000; | |
} | |
return; | |
}, | |
'any' => sub { | |
return if any {$_ == 1000} (1..1000); | |
}, | |
}); |
Author
cynovg
commented
Jan 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment