title: Mojo::UserAgent non-blocking vs blocking performance
body: <p>I have the following code:</p>
  
  <pre><code>my $ua = Mojo::UserAgent-&gt;new ();
  
  my @ids = qw(id1 id2 id3);
  
  foreach (@ids) {    
      my $input = $_;
      my $res = $ua-&gt;get('http://my_site/rest/id/'.$input.'.json' =&gt; sub {
          my ($ua, $res) = @_;
          print "$input =&gt;" . $res-&gt;result-&gt;json('/net/id/desc'), "\n";
      });    
  }
  
  Mojo::IOLoop-&gt;start unless Mojo::IOLoop-&gt;is_running;
  </code></pre>
  
  <p>Why when I run the above code (non-blocking) does it take about 6 seconds while when running the code as blocking, i.e. inside the loop something like:</p>
  
  <pre><code> my $res = $ua-&gt;get('http://my_site/rest/id/'.$input.'.json');
   print "$input =&gt;" . $res-&gt;result-&gt;json('/net/id/desc'), "\n";
  </code></pre>
  
  <p>without the latest line it takes about 1 second?</p>
  
  <p>Why is the blocking code faster than the non-blocking code?</p>