[fpc-pascal] Happy tickets benchmark
Martin Schreiber
mse00000 at gmail.com
Sat Feb 13 14:23:08 CET 2016
On Saturday 13 February 2016 11:44:27 Serguei TARASSOV wrote:
> Hello,
>
> Here is my little brute-force test for FPC, C and C# compilers.
> http://arbinada.com/main/en/node/1532
>
A slightely modified testcase because MSElang has no RTL yet:
"
program test;
var
n1, n2, n3, n4, n5, n6, n7, n8: 0..9;
TicketsCount: int32;
i1: int32;
begin
for i1:= 0 to 9 do begin
TicketsCount := 0;
for n1 := 0 to 9 do
for n2 := 0 to 9 do
for n3 := 0 to 9 do
for n4 := 0 to 9 do
for n5 := 0 to 9 do
for n6 := 0 to 9 do
for n7 := 0 to 9 do
for n8 := 0 to 9 do
if n1 + n2 + n3 + n4 = n5 + n6 + n7 + n8 then
inc(TicketsCount);
end;
writeln('Found ', TicketsCount, ' tickets.');
end.
"
"
#include <stdio.h>
#include <stdint.h>
int main()
{
unsigned char n1, n2, n3, n4, n5, n6, n7, n8;
int i1;
int tickets_count;
for (i1 = 0; i1 < 10; i1++){
tickets_count = 0;
for (n1 = 0; n1 < 10; n1++)
for (n2 = 0; n2 < 10; n2++)
for (n3 = 0; n3 < 10; n3++)
for (n4 = 0; n4 < 10; n4++)
for (n5 = 0; n5 < 10; n5++)
for (n6 = 0; n6 < 10; n6++)
for (n7 = 0; n7 < 10; n7++)
for (n8 = 0; n8 < 10; n8++)
if (n1 + n2 + n3 + n4 == n5 + n6 + n7 + n8)
tickets_count++;
}
printf("Found %i tickets.",tickets_count);
return 0;
}
"
MSElang with LLVM 3.7.0 backend -O3:
"
time ./test.bin
Found 4816030 tickets.
real 0m0.997s
user 0m0.993s
sys 0m0.003s
"
FPC 3.0 -O3:
"
time ./testfpc.bin
Found 4816030 tickets.
real 0m5.576s
user 0m5.572s
sys 0m0.002s
"
gcc 4.8.1 -O3:
"
time ./testgcc.bin
Found 4816030 tickets.
real 0m1.649s
user 0m1.645s
sys 0m0.002s
"
Stripped binary size:
MSElang 5.5KB
FPC 3.0 21.6KB
gcc 4.8.1 5.5KB
Linux x86, AMD Athlon 4000+ 1GHz
Martin
More information about the fpc-pascal
mailing list