performance measurements

Each table row shows performance measurements for this Perl program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1,000Failed  579   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read mandelbrot benchmark to see what this program should do.

 notes

This is perl 5, version 18, subversion 0 (v5.18.0) built for i686-linux

Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
                        PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_LARGE_FILES
                        USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF

 mandelbrot Perl program source code

# The Computer Language Benchmarks Game
#  http://benchmarksgame.alioth.debian.org/
#
#  contributed by Mykola Zubach

use strict;
use threads;
use threads::shared;

use constant MAXITER => 50;
use constant LIMIT => 4.0;
use constant XMIN => -1.5;
use constant YMIN => -1;
use constant WHITE => "\0";
use constant BLACK => "\001";

my ($w, $h, @threads, $invN);
my @jobs :shared;
my @picture :shared;

sub draw_line($) {
   my $y = shift;
   my $line;
   my $Ci = $y * $invN + YMIN;
X:
   for my $x (0 .. $w - 1) {
      my ($Zr, $Zi, $Tr, $Ti);
      my $Cr = $x * $invN + XMIN;

      for (1 .. MAXITER) {
         $Zi = $Zi * 2 * $Zr + $Ci;
         $Zr = $Tr - $Ti + $Cr;
         $Ti = $Zi * $Zi;
         $Tr = $Zr * $Zr;
         if ($Tr + $Ti > LIMIT) {
            $line .= WHITE;
            next X;
         }
      }
      $line .= BLACK;
   }
   $picture[$y] = pack 'B*', $line;
}

sub process_queue() {
   while(defined(my $y = pop @jobs)) {
      draw_line($y);
   }
}

sub num_cpus() {
   open my $fh, '</proc/cpuinfo' or return 4;
   my $cpus;
   while(<$fh>) {
      $cpus ++ if /^processor\s+:/;
   }
   return $cpus;
}

## MAIN()

$w = $h = shift || 200;
$invN = 2 / $w;
@jobs = (0 .. $h - 1);

for (1 .. num_cpus()) {
   push @threads, threads->create(\&process_queue);
}

for (@threads) {
   $_->join;
}

print "P4\n$w $h\n"; # PBM image header
print @picture;

 make, command-line, and program output logs

Tue, 14 Jan 2014 23:52:02 GMT

COMMAND LINE:
/usr/local/src/perl-5.18.0_no_ithreads_no_multi/bin/perl mandelbrot.perl 1000

PROGRAM FAILED 


(BINARY) PROGRAM OUTPUT NOT SHOWN

This Perl not built to support threads
Compilation failed in require at mandelbrot.perl line 7.
BEGIN failed--compilation aborted at mandelbrot.perl line 7.

Revised BSD license

  Home   Conclusions   License   Play