User forums > Using Code::Blocks

Code Profiler: Problem with gprof under WINDOWS

(1/5) > >>

zak:
I have some problem with gprof under WINDOWS
with C:B 5082.
I remember that it has worked in the past..
 
This is the wrong result of my test code under WINDOWS XP


--- Code: ---Each sample counts as 0.01 seconds.
no time accumulated

  %  cumulative  self              self    total         
time  seconds  seconds    calls  Ts/call  Ts/call  name   
  0.00      0.00    0.00      500    0.00    0.00  f(int)
  0.00      0.00    0.00      500    0.00    0.00  g(int)
.
.
.
granularity: each sample hit covers 0 byte(s) no time propagated



index % time    self  children    called     name

                0.00    0.00     500/500         _main [53]

[3]      0.0    0.00    0.00     500         f(int) [3]

-----------------------------------------------

                0.00    0.00     500/500         _main [53]

[4]      0.0    0.00    0.00     500         g(int) [4]

-----------------------------------------------



--- End code ---

and this is the correct version under LINUX
where it works fine


--- Code: ---Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name   
 79.66      0.47     0.47      250     1.88     1.88  f(int)
 20.34      0.59     0.12      250     0.48     0.48  g(int)
.
,
,
granularity: each sample hit covers 4 byte(s) for 1.69% of 0.59 seconds

index % time    self  children    called     name
                                                 <spontaneous>
[1]    100.0    0.00    0.59                 main [1]
                0.47    0.00     250/250         f(int) [2]
                0.12    0.00     250/250         g(int) [3]
-----------------------------------------------
                0.47    0.00     250/250         main [1]
[2]     79.7    0.47    0.00     250         f(int) [2]
-----------------------------------------------
                0.12    0.00     250/250         main [1]
[3]     20.3    0.12    0.00     250         g(int) [3]
-----------------------------------------------

--- End code ---

Here i put the test code

--- Code: ---#include <sys/time.h>

#define rdtscll(val) asm volatile("rdtsc" : "=A" (val))

struct timeval tv;
unsigned long long t;

void f (int n)
{
  int x, y, z = 0;

  for (x = 0; x < n; x++)
    for (y = 0; y < n; y++) {
      z += x * y;
      rdtscll (t);
    }
}

void g (int n)
{
  int x, y, z = 0;

  for (x = 0; x < n; x++)
    for (y = 0; y < n; y++) {
      z += x * y;
      gettimeofday (&tv, 0);
    }
}

int main (int argc, char *argv[])
{
  int n;

  for (n = 0; n < 500; n++) {
    if (n % 2)
      f (n);
    else
      g (n);
  }
  return 0;
}

--- End code ---

Where is the problem?? I miss some library or what???

Any help is appreciated.

Thanks very much, Zak



Biplab:
Please don't post your problem multiple times. Your post may be locked for spamming. If noone answers to your query you need to wait.

Check that you compiled with -g option and linked against libgprof.a (hopefully I'm correct).

zak:
I'm sorry for multiple posting.

I compiled with -g -pg (when I compile without -g I get an error from Code Profiler).

Maybe the problem is libgprof.a, I have not it.

What can I do?


Tanks very much Biplab!

Best regards, Zak

Biplab:

--- Quote from: zak on June 09, 2008, 02:25:54 pm ---I compiled with -g -pg (when I compile without -g I get an error from Code Profiler).

Maybe the problem is libgprof.a, I have not it.

What can I do?

--- End quote ---

Run it once before launching the Code-profiler plugin.

zak:
Sorry, I'm going to explain better the problem.

I know how gprof works.

I must compile with -pg and -g.
I must run the program.
If the prograg exit with 0 code i can start plugin (or gprof directly)
and see the call graph.

Now, i have a code. I compile it with g++ under Linux (Ubuntu 8.4)
using Codeblocks IDE and the Code Profiler works fine.

When I compile with g++ under Windows Xp using the same versione of
Codeblocks, just those for Windows, and i run it...

I obtain all 0.00 time.

In the Windows version i don't need link with libgprof.a, there is a Profiler.dll file
in the directory C:\Programmi\Codeblocks\Share\Plugins.

I hope to be clear the problem.

However, Thanks very Much for your reply.

Best regards, Zak


Navigation

[0] Message Index

[#] Next page

Go to full version