profilingturbo-cturbo-pascal

Profiling computations in Turbo Pascal and Turbo C


I recently been doing some tasks for university, which include using Turbo Profiler (the software is implicitly declared in the task, sadly) for profiling C and Pascal implementations of Simpsons numerical integration. I came across very strange case, where Pascal is suspiciously much faster than C.

Pascal:

i: integer, lower: real, delta_x: real;
....
(0.0000 seconds) (30 times)         x:=lower+delta_x*(2.0*i-1.0);

C:

long i, double lower, double delta_x;
....
(0.0549 seconds) (30 times)         double x = lower + delta_x * (2.0 * i - 1.0);

So, what could it be, the difference between real and double (and integer and long) or just Pascal's compiler better at processing math operations?


Solution

  • Don't believe those numbers. If you want to measure time, put a loop of 10^6 or 10^9 iterations around the top subroutine, and count seconds. If you want to see what fraction of time goes into that statement, use stack-sampling.