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,0001.150.30324748  97% 97% 100% 100%
4,00018.144.551,628748  100% 100% 100% 100%
16,000289.8772.5930,980748  100% 100% 100% 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 #4 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

  modified by Jeppe Johansen

}

program mandelbrot;

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

const
  Limit = 4.0;
  ThreadCount = 4;

var
  n, dimx : longint;
  nInv: double;
  TextBuf: pbyte;

  yCounter: longint;

function subThread(p: pointer) : ptrint;
var
  x, y, i, bits, bit, buf_index: Longint;
  Zr, Zi, Ti, Tr, Cr, Ci : Double;
begin
  while true do
  begin
    y := interlockedincrement(yCounter)-1;

    if y >= n then break;

    buf_index := y*dimx;

    prefetch(TextBuf[buf_index]);

    bit := 128; // 1000 0000


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


      Zr := 0;
      Zi := 0;
      Tr := 0;
      Ti := 0;
      Cr := ((x + x) * nInv) - 1.5;
      for i := 1 to 50 do
      begin
        Zi := 2.0 * 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, t, buf_index: Longint;
  tt : array[0..ThreadCount-1] of TThreadID;
begin
  nInv := 1/n;

  for i := 0 to ThreadCount-1 do
    tt[i] := BeginThread(@subThread, nil);

  for i := 0 to ThreadCount-1 do
    WaitForThreadTerminate(tt[i], 0);

  buf_index := 0;
  i := n*dimx;
  while buf_index < i do
  begin
    t := FileWrite(StdOutputHandle, TextBuf[buf_index], i-buf_index);;
    if t >= 0 then
      buf_index := buf_index + t;
  end;
end;

begin
  Val(ParamStr(1), n);
  write('P4', chr(10), n, ' ', n, chr(10));
  Flush(output);

  dimx := Ceil(n / 8);

  TextBuf := GetMem(dimx*n);

  run;

  freemem(textbuf);
end.

 make, command-line, and program output logs

Fri, 25 Apr 2014 01:47:44 GMT

MAKE:
mv mandelbrot.fpascal-4.fpascal mandelbrot.fpascal-4.pas
/usr/local/src/fpc-2.6.4.i386-linux/bin/fpc -FuInclude/fpascal -XXs -Oppentiumm -Cppentiumm -O3 -Cfsse2  -oFPASCAL_RUN mandelbrot.fpascal-4.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-4.pas
Linking FPASCAL_RUN
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
118 lines compiled, 0.2 sec 
mv FPASCAL_RUN mandelbrot.fpascal-4.fpascal_run
rm mandelbrot.fpascal-4.pas
0.21s to complete and log all make actions

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

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play