Don't like ads? PRO users don't see any ads ;-)
Guest

increment benchmark

By: a guest on May 25th, 2012  |  syntax: Perl  |  size: 0.18 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use Benchmark ':all';
  7.  
  8. my $i = 0;
  9. timethis(
  10.   30000000,
  11.   sub { ++$i }
  12. );
  13.  
  14. $i = 0;
  15. timethis(
  16.   30000000,
  17.   sub { $i++ }
  18. );