Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Last active July 8, 2020 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDaniel/cbac99a8c725857d6c3877c35436528f to your computer and use it in GitHub Desktop.
Save AlexDaniel/cbac99a8c725857d6c3877c35436528f to your computer and use it in GitHub Desktop.
Very basic benchmark provided by jdv79
#!/usr/bin/env julia
pat = r"^
(?<date> \S+ ) \s+
(?<time> \S+ ) \s+
(?<size> \S+ ) \s+
(?<path> \S+ )
$"x
for line ∈ readlines()
m = match(pat, line)
m === nothing && throw("invalid line")
(date, time, size, path) = (m[:date], m[:time], m[:size], m[:path])
end
#!/usr/bin/env raku
my $pat = rx/^
$<date>=[\S+]\s+
$<time>=[\S+]\s+
$<size>=[\S+]\s+
$<path>=[\S+]
$/;
lines().map: {
die "invalid line" unless $_ ~~ $pat;
my %parts = $/;
}
#!/usr/bin/env perl
use strict;
use warnings;
while (<>) {
my ($date, $time, $size, $path) = my @parts
= $_ =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/;
die "invalid line" unless @parts == 4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment