mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 14:19:28 +02:00
+ added mandelbrot benchmark
git-svn-id: trunk@5265 -
This commit is contained in:
parent
11fcbcc663
commit
56196fc242
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -5422,6 +5422,7 @@ tests/bench/shootout/src/bench.c -text
|
||||
tests/bench/shootout/src/binarytrees.pp svneol=native#text/plain
|
||||
tests/bench/shootout/src/hello.pp svneol=native#text/plain
|
||||
tests/bench/shootout/src/knucleotide.pp svneol=native#text/plain
|
||||
tests/bench/shootout/src/mandelbrot.pp svneol=native#text/plain
|
||||
tests/bench/shootout/src/nsieve.pp svneol=native#text/plain
|
||||
tests/bench/shootout/src/partialsums.pp svneol=native#text/plain
|
||||
tests/bench/shootout/src/recursive.pp svneol=native#text/plain
|
||||
|
67
tests/bench/shootout/src/mandelbrot.pp
Normal file
67
tests/bench/shootout/src/mandelbrot.pp
Normal file
@ -0,0 +1,67 @@
|
||||
{ The Computer Language Shootout
|
||||
http://shootout.alioth.debian.org
|
||||
|
||||
contributed by Ales Katona
|
||||
modified by Vincent Snijders
|
||||
}
|
||||
|
||||
program mandelbrot;
|
||||
|
||||
{$FPUTYPE SSE2}{$I-}
|
||||
|
||||
var n, x, y, bits,bit: Longint;
|
||||
Cx, Cy: double;
|
||||
|
||||
procedure CalculatePoint; nostackframe;
|
||||
const
|
||||
Limit: double =4.0;
|
||||
zero: double = 0.0;
|
||||
var
|
||||
i: longint;
|
||||
OutOfLimit: boolean;
|
||||
Cr, Ci, Zr, Zi, Ti, Tr: Double;
|
||||
|
||||
begin
|
||||
Cr := Cx; Ci := Cy;
|
||||
Zr := zero; Zi := zero; Tr := zero; Ti := zero;
|
||||
i := 0;
|
||||
repeat
|
||||
Zi := 2*Zr*Zi + Ci;
|
||||
Zr := Tr - Ti + Cr;
|
||||
Ti := Zi * Zi;
|
||||
Tr := Zr * Zr;
|
||||
inc(i);
|
||||
OutOfLimit := (Tr + Ti>=limit);
|
||||
until OutOfLimit or (i=50);
|
||||
|
||||
if OutOfLimit then
|
||||
bits := bits xor bit;
|
||||
end;
|
||||
|
||||
{$FPUTYPE X87}
|
||||
|
||||
begin
|
||||
Val(ParamStr(1), n);
|
||||
writeln('P4');
|
||||
writeln(n,' ',n);
|
||||
for y := 0 to n-1 do
|
||||
begin
|
||||
Cy := y * 2 / n - 1;
|
||||
bits := 255; bit := 128;
|
||||
for x := 0 to n-1 do
|
||||
begin
|
||||
Cx := x * 2 / n - 1.5;
|
||||
|
||||
CalculatePoint;
|
||||
|
||||
if bit > 1 then
|
||||
bit := bit shr 1
|
||||
else
|
||||
begin
|
||||
write(chr(bits));
|
||||
bits := 255; bit := 128;
|
||||
end;
|
||||
end;
|
||||
if bit < 128 then write(chr(bits xor((bit shl 1)-1)));
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user