Pascal Dialects


Apple Pascal

program Ahl(input, output);

uses transcen,applestu;

var
  r,s,a : real;
  i,n: integer;

begin
  writeln("ahl.apple.text -- The Apple Pascal version of Ahl's simple benchmark");
  r:=0; 
  s:=0;
  for n:=1 to 100 do 
  begin
    a := n;
    for i:=1 to 10 do
    begin
      a := sqrt(a); 
      r := r + 1.0/32767.0*random;
    end;
    for i:=1 to 10 do
    begin
      a := a*a; 
      r := r + 1.0/32767.0*random;
    end;
    s := s + a;
  end;
  writeln("Accuracy ",abs(1010.0-s/5.0));
  writeln("Random ",abs(1000.0-r));
end.


Sun Pascal

program Ahl(input, output);
{ Ahl's simple benchmark }
var
  r,s,a : real;
  i,n,iter : integer;
  t,t1: integer;

begin
  writeln("ahl.p -- The Sun Pascal version of Ahl's simple benchmark");
  r:=0; 
  s:=0;
  time(t);
  t1=t
  while (t=t1) do
    time(t1);
  time(t);
  repeat
    iter := iter + 1;
    r:=0; 
    s:=0;
    for n:=1 to 100 do 
    begin
      a := n;
      for i:=1 to 10 do
      begin
        a := sqrt(a); 
        r := r + random;
      end;
      for i:=1 to 10 do
      begin
        a := a*a; 
        r := r + random;
      end;
      s := s + a;
    end;
    time(t1);
  until  ((t1-t)>20);
  t=time(0) - t;
  writeln(iter," iterations");
  writeln(t/iter," seconds per iteration");
  writeln("Accuracy ",abs(1010.0-s/5.0));
  writeln("Random ",abs(1000.0-r));
end.


Copyright © 2001 Eric Korpela
korpela@ssl.berkeley.edu