Does additional code in the :content_cb
-callback slow down the download?
Supposed the additional code would take 1_000/1_000_000 seconds to run and the callback gets called 1_000 times, would that slow down the download for 1_000/1_000_000 * 1_000 seconds?
#!/usr/bin/env perl
use warnings;
use 5.012;
use Time::HiRes qw(usleep);
use File::Basename;
use LWP::UserAgent;
my $url = 'my_url';
my $file_name = basename $url;
my $ua = LWP::UserAgent->new();
open my $fh, '>>:raw', $file_name or die $!;
my $res = $ua->get(
$url,
':content_cb' => sub {
my ( $chunk, $res, $proto ) = @_;
print $fh $chunk;
usleep( 1000 ); # code substitute
},
);
close $fh;