/mobile Handheld Friendly website

 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

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 #3 program source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org/
#
# contributed by Rodrigo de Almeida Siqueira

use strict;

my $MAXITER = 50;
my $LIMIT = 4;
my $xmin = -1.5;
my $ymin = -1;

my ($w, $h);

$w = $h = shift || 200;
my $invN = 2/$w;

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

my $checknext=1;

for my $y (0..$h-1) {

  my @v;

  my $Ci = $y * $invN + $ymin;

  X:
  for my $x (0..$w-1) {

    my ($Zr, $Zi, $Tr, $Ti);

    my $Cr = $x * $invN + $xmin;

    if ($checknext) {

        # Iterate with checking (likely outer pixel)
        for (1..$MAXITER) {
          $Zi = 2 * $Zr * $Zi + $Ci;
          $Zr = $Tr - $Ti + $Cr;
          $Ti = $Zi * $Zi;
          $Tr = $Zr * $Zr;

          if ($Tr + $Ti > $LIMIT) {
            push @v, 0; # White pixel
            next X;
          }
        }

        push @v, 1;     # Black pixel
        $checknext = 0; # Is inner pixel.

    } else {

      # Iterate without checking (likely inner pixel)

      for (1..$MAXITER) {
        $Zi = 2 * $Zr * $Zi + $Ci;
        $Zr = $Tr - $Ti + $Cr;
        $Ti = $Zi * $Zi;
        $Tr = $Zr * $Zr;
      }

      if ($Tr+$Ti <= 4) {
        push @v, 1;
      } else { # $Tr+$Ti is a large number or overflow ('nan' or 'inf')
        push @v, 0;
        $checknext = 1;
      }

    }

  }

  print pack 'B*', pack 'C*', @v;

}

 make, command-line, and program output logs

Tue, 21 May 2013 19:09:57 GMT

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

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play