Slow code generation
Original Reporter info from Mantis: s_tarassov
-
Reporter name: Serguei Tarassov
Original Reporter info from Mantis: s_tarassov
- Reporter name: Serguei Tarassov
Description:
The simple program is executed more slow that GNU C counter and more slowly that Delphi7 EXE on the virtual machine under the same host PC!
* FreePascal 2.6 (x64) : 75 sec
* Delphi 7 (x86, on virtual machine hosted by testing PC): 55 sec
* GNU C 4.6 (x64) : 38 sec
Steps to reproduce:
Pascal code (compiled from blank project with Lazarus 1.2.6, all options are by default)
<code>
program Chickens;
var
a1, a2, a3: integer;
x, y: integer;
begin
for x := 1 to 3499 do
for y := 1 to x - 1 do
for a1 := 0 to 10 do
for a2 := 0 to 16 do
for a3 := 0 to 26 do
if (a1 * x + (10 - a1) * y = 3500) and
(a2 * x + (16 - a2) * y = 3500) and
(a3 * x + (26 - a3) * y = 3500)
then
writeln('x = ', x, ', y = ', y,
', a1 = ', a1,
', b1 = ', 10 - a1,
', a2 = ', a2,
', b2 = ', 16 - a2,
', a3 = ', a3,
', b3 = ', 26 - a3
);
writeln('Finished');
readln;
end.
</code>
GNU C code (compiled from blank project with Code::Blocks 13.12, GNU C 4.8.2, all options are by default)
&LtPos;code>
#include &LtPos;stdio.h>
#include &LtPos;stdlib.h>
int main()
{
int a1, a2, a3;
int x, y;
for (x = 1; x < 3500; x++)
for (y = 1; y < x; y++)
for (a1 = 0; a1 <= 10; a1++)
for (a2 = 0; a2 <= 16; a2++)
for (a3 = 0; a3 <= 26; a3++)
if ((a1 * x + (10 - a1) * y == 3500) &&
(a2 * x + (16 - a2) * y == 3500) &&
(a3 * x + (26 - a3) * y == 3500))
printf("x = %d, y = %d, a1 = %d, b1 = %d, a2 = %d, b2 = %d, a3 = %d, b3 = %d\n",
x, y, a1, 10 - a1, a2, 16 - a2, a3, 26 - a3);
printf("Finished\n");
return 0;
}
</code>
Compile and run it.
Mantis conversion info:
- Mantis ID: 27252
- OS: Ubuntu
- OS Build: 14.04
- Platform: Ubuntu x84
- Version: 2.6.4
- Monitored by: » s_tarassov (Serguei Tarassov), » Vincent (Vincent Snijders)