Skip to content

Instantly share code, notes, and snippets.

@foursixnine
Created December 6, 2016 14:11
Show Gist options
  • Save foursixnine/80403aa86ae5d77dac0f1b776d476f79 to your computer and use it in GitHub Desktop.
Save foursixnine/80403aa86ae5d77dac0f1b776d476f79 to your computer and use it in GitHub Desktop.
Quick test to see if using unlink is fast enough vs just symlinking directly.
use strict;
use warnings;
use Benchmark::Stopwatch;
my $stopwatch = Benchmark::Stopwatch->new->start;
my $i = 0;
$stopwatch->lap("start");
opendir(my $dh, ".") || die "Can't open dir : $!";
while (readdir $dh) {
next if /last|linktest/;
$i++;
unlink("last.png");
symlink($_, "last.png");
$stopwatch->lap("Link_$_");
}
print $stopwatch->summary(); #bogus, this can't handle time in ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment