I have this program that takes 2.34 seconds to run, and gprof says it only takes 1.18 seconds. I've read answers elsewhere suggesting that gprof can get it wrong if e.g the program is I/O bound, but this program clearly isn't.
This also happens for a useful program I'm trying to profile. It's not specific to this trivial test case.
(Also in this case gprof says that main() takes more than 100% of the program's running time, which is a pretty stupid bug but not really causing problems for me.)
$ cat test.c
int main() {
    int i;
    for (i=0;i<1000000000;i++);
}
$ gcc test.c -o test
$ time ./test
real    0m2.342s
user    0m2.340s
sys 0m0.000s
$ gcc test.c -o test -pg
$ time ./test
real    0m2.342s
user    0m2.340s
sys 0m0.000s
$ gprof test |head
Flat profile:
Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
101.33      1.18     1.18                             main
 %         the percentage of the total running time of the
time       program used by this function.
 
     
     
     
    