help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gcc -O3 & gprof


From: Alex Vinokur
Subject: gcc -O3 & gprof
Date: Mon, 17 Mar 2003 14:00:29 +0200

=====================
Windows 2000
DJGPP 2.03
GNU gcc version 3.2.1
GNU gprof 2.13
=====================


Here is a simple program that has been profiled with using gprof.
We can see that if the program is compiled with option -O3
 then gprof's output doesn't contained called functions foo1() and foo2().

Any explanation ?


========= C code : BEGIN =========
/* File main.c */

int foo1 (int argc) { return argc; }
int foo2 (int argc) { return argc; }

int main(int argc)
{
  return (foo1(argc) + foo2(argc));
}

========= C code : END ===========


========= Compiling & Running : BEGIN =========

% gcc -o a0.exe main.c -g -pg
% a0.exe
% gprof -b a0.exe

Flat profile:

Each sample counts as 0.0555556 seconds.
 no time accumulated

  %   cumulative   self              self     total
 time   seconds   seconds    calls  Ts/call  Ts/call  name
  0.00      0.00     0.00        1     0.00     0.00  foo1
  0.00      0.00     0.00        1     0.00     0.00  foo2
  0.00      0.00     0.00        1     0.00     0.00  main
[---omitted---]


-----------------------------------------------
% gcc -O1 -o a1.exe main.c -g -pg
% a1.exe
% gprof -b a1.exe

Flat profile:

Each sample counts as 0.0555556 seconds.
 no time accumulated

  %   cumulative   self              self     total
 time   seconds   seconds    calls  Ts/call  Ts/call  name
  0.00      0.00     0.00        1     0.00     0.00  foo1
  0.00      0.00     0.00        1     0.00     0.00  foo2
  0.00      0.00     0.00        1     0.00     0.00  main
[---omitted---]



-----------------------------------------------
% gcc -O2 -o a2.exe main.c -g -pg
% a2.exe
% gprof -b a2.exe

Flat profile:

Each sample counts as 0.0555556 seconds.
 no time accumulated

  %   cumulative   self              self     total
 time   seconds   seconds    calls  Ts/call  Ts/call  name
  0.00      0.00     0.00        1     0.00     0.00  foo1
  0.00      0.00     0.00        1     0.00     0.00  foo2
  0.00      0.00     0.00        1     0.00     0.00  main
[---omitted---]


-----------------------------------------------
% gcc -O3 -o a3.exe main.c -g -pg
% a3.exe
% gprof -b a3.exe

Flat profile:

Each sample counts as 0.0555556 seconds.
 no time accumulated

  %   cumulative   self              self     total
 time   seconds   seconds    calls  Ts/call  Ts/call  name
  0.00      0.00     0.00        1     0.00     0.00  main
[---omitted---]

========= Compiling & Running : END ===========


   =================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://www.simtel.net/pub/oth/19088.html
   =================================







reply via email to

[Prev in Thread] Current Thread [Next in Thread]