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
5000.130.14?423  0% 0% 0% 100%
3,0004.694.698423  1% 0% 1% 100%
5,50015.7615.768423  0% 0% 0% 100%

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

Read spectral-norm 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.

 spectral-norm Pascal Free Pascal program source code

{ The Computer Language Benchmarks Game

  http://benchmarksgame.alioth.debian.org



  contributed by Ian Osgood

  modified by Vincent Snijders

}

program spectralNorm;


var n,i : integer;
    u,v,tmp : array of double;
    vBv,vv : double;

function A(i,j : integer): double; inline;
begin
  A := 1 / ((i+j)*(i+j+1) div 2 + i+1);
end;

procedure mulAv(var v, Av : array of double);
var i,j : integer;
begin
  for i := low(Av) to high(Av) do
  begin
    Av[i] := 0.0;
    for j := low(v) to high(v) do
      Av[i] := Av[i] + A(i,j) * v[j];
  end;
end;

procedure mulAtv(var v, Atv : array of double);
var i,j : integer;
begin
  for i := low(Atv) to high(Atv) do
  begin
    Atv[i] := 0.0;
    for j := low(v) to high(v) do
      Atv[i] := Atv[i] + A(j,i) * v[j];
  end;
end;

procedure mulAtAv(var v, AtAv : array of double);
begin
  mulAv(v, tmp);
  mulAtv(tmp, AtAv);
end;

begin
  Val(paramstr(1), n, i);
  SetLength(u, n);
  SetLength(v, n);
  SetLength(tmp, n);

  for i := low(u) to high(u) do u[i] := 1.0;

  for i := 1 to 10 do begin mulAtAv(u,v); mulAtAv(v,u) end;

  for i := low(u) to high(u) do
  begin
    vBv := vBv + u[i]*v[i];
    vv  := vv  + v[i]*v[i];
  end;

  writeln(sqrt(vBv/vv):0:9);
end.

 make, command-line, and program output logs

Fri, 25 Apr 2014 03:34:35 GMT

MAKE:
mv spectralnorm.fpascal spectralnorm.pas
/usr/local/src/fpc-2.6.4.i386-linux/bin/fpc -FuInclude/fpascal -XXs -Oppentiumm -Cppentiumm -O3 -Cfsse2  -oFPASCAL_RUN spectralnorm.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 spectralnorm.pas
spectralnorm.pas(60,12) Warning: Variable "vBv" does not seem to be initialized
spectralnorm.pas(61,12) Warning: Variable "vv" does not seem to be initialized
Linking FPASCAL_RUN
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
65 lines compiled, 0.1 sec 
2 warning(s) issued
mv FPASCAL_RUN spectralnorm.fpascal_run
rm spectralnorm.pas
0.10s to complete and log all make actions

COMMAND LINE:
./spectralnorm.fpascal_run 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play