performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1,0000.310.328530  3% 100% 6% 3%
4,0004.944.948530  1% 1% 0% 100%
16,00078.7278.758530  1% 100% 0% 0%

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

Free Pascal Compiler version 2.6.4 [2014/03/03] for i386

Low memory use compared to other language implementations - because Free Pascal statically links programs by default, avoiding libc.

 mandelbrot Pascal Free Pascal #3 program source code

{ The Computer Language Benchmarks Game

  http://benchmarksgame.alioth.debian.org



  contributed by Ales Katona

  modified by Vincent Snijders

}

program mandelbrot;

var n: longint;
    TextBuf: array[0..$FFF] of byte;
    OutFile: PText;
    

procedure run;
var
  Cy, Step: double;
  x, y, bits,bit: Longint;
  function CalculatePoint(Cx, Cy: double): boolean; nostackframe; inline;
  const
    Limit = 4;
  var
    i: longint;
    Zr, Zi, Ti, Tr: Double;

  begin
    Zr := 0;  Zi := 0; Tr := 0; Ti := 0;
    for i := 1 to 50 do begin
      Zi := 2*Zr*Zi + Cy;
      Zr := Tr - Ti + Cx;
      Ti := Zi * Zi;
      Tr := Zr * Zr;
      if (Tr + Ti>=limit) then exit(true);
    end;

    CalculatePoint := false;
  end;

begin
  Step := 2/n;
  for y := 0 to n-1 do
  begin
    Cy := y * Step - 1;
    bits := 255;  bit := 128;
    for x := 0 to n-1 do
    begin
      if CalculatePoint(x * Step  - 1.5, Cy) then
        bits := bits xor bit;

      if bit > 1 then
        bit := bit shr 1
      else
      begin
        write(OutFile^, chr(bits));
        bits := 255;  bit := 128;
      end;
    end;
    if bit < 128 then write(OutFile^, chr(bits xor((bit shl 1)-1)));
  end;
end;

begin
  OutFile := @Output;
  SetTextBuf(OutFile^, TextBuf);

  Val(ParamStr(1), n);
  writeln(OutFile^, 'P4');
  writeln(OutFile^, n,' ',n);
  run;
end.

 make, command-line, and program output logs

Fri, 25 Apr 2014 01:49:03 GMT

MAKE:
mv mandelbrot.fpascal-3.fpascal mandelbrot.fpascal-3.pas
/usr/local/src/fpc-2.6.4.i386-linux/bin/fpc -FuInclude/fpascal -XXs -Oppentiumm -Cppentiumm -O3 -Cfsse2  -oFPASCAL_RUN mandelbrot.fpascal-3.pas
Free Pascal Compiler version 2.6.4 [2014/03/03] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling mandelbrot.fpascal-3.pas
Linking FPASCAL_RUN
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
70 lines compiled, 0.1 sec 
mv FPASCAL_RUN mandelbrot.fpascal-3.fpascal_run
rm mandelbrot.fpascal-3.pas
0.09s to complete and log all make actions

COMMAND LINE:
./mandelbrot.fpascal-3.fpascal_run 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play