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.330.33324817  0% 3% 0% 97%
4,0005.265.262,532817  1% 3% 0% 100%
16,00083.6083.6232,948817  0% 0% 1% 100%

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

 mandelbrot Pascal Free Pascal #2 program source code

{ The Computer Language Benchmarks Game

  http://benchmarksgame.alioth.debian.org



  contributed by Ales Katona

  modified by Vincent Snijders

  optimized and multithreaded by Jean de La Taille 

}

program mandelbrot;

uses
  {$ifdef unix}cthreads,{$endif}
  sysUtils, dateUtils, math;

const
  Limit = 4;

var
  n, n_1, dimx, dimy : longint;
  TextBuf: array of byte;
  start, finish : TDateTime;

type
  mem = record
    from_y, to_y : longint;
  end;
  pmem = ^mem;

function subThread(p: pointer) : longint;
var
  x, y, from_y, to_y, buf_index, i: Longint;
  Zr, Zi, Ti, Tr : Double;
  Cr, Ci : Double;
  bits: Longint;
  bit: Longint;
begin
  from_y := pmem(p)^.from_y;
  to_y := pmem(p)^.to_y;
  buf_index := from_y * dimx;
  for y := from_y to to_y do
  begin
    bit := 128; // 1000 0000

    bits := 0;
    Ci := ((y + y) / n) - 1.0;
    for x := 0 to n_1 do
    begin
      //---------------------------

      Zr := 0;
      Zi := 0;
      Tr := 0;
      Ti := 0;
      Cr := ((x + x) / n) - 1.5;
      for i := 1 to 50 do
      begin
        Zi := 2 * Zr * Zi + Ci;
        Zr := Tr - Ti + Cr;
        Ti := Zi * Zi;
        Tr := Zr * Zr;
        if ((Tr + Ti) > limit) then
        begin
          bits := bits or bit;
          break;
        end;
      end;
      //---------------------------

      bit := bit >> 1;
      if (bit = 0) then
      begin
        TextBuf[buf_index] := not bits;
        inc(buf_index);
        bits := 0;
        bit := 128;
      end;
    end;
  end;
  subThread := 0;
end;

procedure run;
var
  i, l, x, y, buf_index: Longint;
  tt : array[0..3] of TThreadID;
  m : array[0..3] of mem;
  stepL : longint;
begin
  n_1 := n - 1;
  l := 0;
  stepL := floor(n / 4);

  start := now;
  for i := 0 to 2 do
  begin
    m[i].from_y := l;
    m[i].to_y := l + stepL - 1;
    tt[i] := BeginThread(@subThread, @m[i]);
    l := l + stepL;
  end;
  m[3].from_y := l;
  m[3].to_y := n_1;
  tt[3] := BeginThread(@subThread, @m[3]);
  for i := 0 to 3 do
    WaitForThreadTerminate(tt[i], 0);
  finish := now;
  //WriteLn('Time : ', MilliSecondsBetween(start, finish) / 1000 : 0 : 4);


  buf_index := 0;
  for y := 0 to n_1 do
    for x := 0 to dimx - 1 do
    begin
      write(chr(TextBuf[buf_index]));;
      inc(buf_index);
    end;
end;


begin
  Val(ParamStr(1), n);
  write('P4', chr(10), n, ' ', n, chr(10));
  //write('P5', chr(10), n, ' ', n, chr(10), 255, chr(10));


  dimx := Ceil(n / 8);
  dimy := n;
  SetLength(TextBuf, (dimx * dimy) + 1);

  start := now;

  run;

  finish := now;
end.


 make, command-line, and program output logs

Fri, 25 Apr 2014 02:42:27 GMT

MAKE:
mv mandelbrot.fpascal-2.fpascal mandelbrot.fpascal-2.pas
/usr/local/src/fpc-2.6.4.i386-linux/bin/fpc -FuInclude/fpascal -XXs -Oppentiumm -Cppentiumm -O3 -Cfsse2  -oFPASCAL_RUN mandelbrot.fpascal-2.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-2.pas
mandelbrot.fpascal-2.pas(21,3) Note: Local variable "start" is assigned but never used
mandelbrot.fpascal-2.pas(21,10) Note: Local variable "finish" is assigned but never used
Linking FPASCAL_RUN
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
132 lines compiled, 0.2 sec 
2 note(s) issued
mv FPASCAL_RUN mandelbrot.fpascal-2.fpascal_run
rm mandelbrot.fpascal-2.pas
0.20s to complete and log all make actions

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

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play