When writing my paper concerning Pascal and C I noticed the following:
For the "Hello World" program the Pascal executeable was 42484 bytes and the C executeable was 4822 bytes.
Using the time command the real was .003s for each of the 5 invocations of the C executeable but was .001s for each of the 5 invocations of the Pascal executeable.
C code:
Code:
#include <stdio.h>
int main (void)
{
printf("Hello World\n");
return 0;
}
Pascal code:
Code:
begin
writeln('Hello World');
end.
The other program was showing how the subroutine definations are(or can be) arranged in C and Pascal.
Pascal Executable 46212, C Executable 5012.
time: C: .003s for each of 5 invocations. Pascal: .001 for 4 of the 5 invocations, .002 for the 5th.
C code
Code:
#include <stdio.h>
void p1 (int);
void p2 (int);
void p3 (int);
int main (void)
{
int x;
x = 5;
printf("%d ",x);
p1(x);
return 0;
}
void p3 (int x)
{
printf("%d\n", x*x);
}
void p1 (int x)
{
x = x + 1;
printf("%d ", x);
p2(x);
}
void p2 (int x)
{
x = x * 2;
printf("%d ", x);
p3(x);
}
Pascal code
Code:
procedure p3 ( x : integer);
begin
writeln(x*x)
end;
procedure p2 ( x : integer);
begin
x := x * 2;
write(x, ' ');
p3(x)
end;
procedure p1 ( x : integer);
begin
x := x + 1;
write (x, ' ');
p2(x)
end;
var
x : integer;
begin
x := 5;
write (x, ' ');
p1(x)
end.
While I'm sure most of you don't care I was suprised on the size of the exectuable and the speed of writting to the screen.
Enviroment: Debian, PII 667 Mhz
Pascal Compiler: Free Pascal Compiler version 1.0.4 [2001/08/31] for i386
C Compiler: gcc version 2.95.4 20011002 (Debian prerelease)