[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gprof - wrong time results
From: |
Jan Schäfer |
Subject: |
Re: gprof - wrong time results |
Date: |
Fri, 08 Apr 2005 17:32:24 +0200 |
User-agent: |
Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
Am Tue, 05 Apr 2005 07:30:22 -0700 schrieb Paul Pluzhnikov:
> Jan Schäfer <schaefer@neuro.informatik.uni-ulm.de> writes:
>
>> any ideas why this does happen?
>
> The most likely cause is that your program spends 95% of its time in
> libc, and you did not link with a profiling version of libc (you'll need
> glibc-prof package installed).
>
> To understand this better, compile/run the test below, examine gprof
> output, then relink it with /usr/lib/libc_p.a and repeat.
>
> Cheers,
>
> --- cut ---
> #include <string.h>
> #include <stdlib.h>
>
> void foo(int count)
> {
> int i;
> char buf[10240];
> for (i = 0; i < count; ++i)
> memset(buf, 0, sizeof(buf));
> }
>
> int main(int argc, char *argv[])
> {
> int i, count = 1000000;
> if (argc > 1) count = atoi(argv[1]);
> foo(count);
> return 0;
> }
> --- cut ---
Hi Paul,
thanks for your reply. I'm already linking with -lc_p. Nevertheless, I
took your little progamm and did some tests on my machine. Without
linking the profiling c-libs I get:
--- time output ---
real 0m1.461s
user 0m1.457s
sys 0m0.002s
--- time output ---
--- flat profile ---
Jedes Muster zählt als 0.01 seconds.
% kumulativ Selbst Selbst Gesamt
Zeit seconds seconds Aufrufe ms/Aufru ms/Aufru Name
100.00 0.05 0.05 1 50.00 50.00 foo(int)
--- flat profile ---
and with -lc_p I get:
--- time output ---
real 0m1.664s
user 0m1.562s
sys 0m0.004s
--- time output ---
--- flat profile ---
Jedes Muster zählt als 0.01 seconds.
% kumulativ Selbst Selbst Gesamt
Zeit seconds seconds Aufrufe s/Aufru s/Aufru Name
99.40 14.90 14.90 1000000 0.00 0.00 memset
0.60 14.99 0.09 1 0.09 14.99 foo(int)
0.00 14.99 0.00 15 0.00 0.00 strncmp
0.00 14.99 0.00 11 0.00 0.00 strlen
0.00 14.99 0.00 8 0.00 0.00 getenv
0.00 14.99 0.00 5 0.00 0.00 __new_exitfn
0.00 14.99 0.00 5 0.00 0.00 _int_malloc
0.00 14.99 0.00 5 0.00 0.00 malloc
0.00 14.99 0.00 3 0.00 0.00 __cxa_atexit
0.00 14.99 0.00 3 0.00 0.00 strsep
0.00 14.99 0.00 2 0.00 0.00 mempcpy
0.00 14.99 0.00 2 0.00 0.00 strpbrk
0.00 14.99 0.00 1 0.00 0.00 __gconv_transform...
0.00 14.99 0.00 1 0.00 0.00 __init_misc
0.00 14.99 0.00 1 0.00 0.00 __libc_csu_fini
0.00 14.99 0.00 1 0.00 0.00 __libc_csu_init
0.00 14.99 0.00 1 0.00 0.00 __libc_init_first
0.00 14.99 0.00 1 0.00 0.00 __libc_init_secure
0.00 14.99 0.00 1 0.00 0.00 __libc_sigaction
0.00 14.99 0.00 1 0.00 14.99 __libc_start_main
0.00 14.99 0.00 1 0.00 0.00 __mbsrtowcs_l
0.00 14.99 0.00 1 0.00 0.00 __setfpucw
0.00 14.99 0.00 1 0.00 0.00 _dl_aux_init
0.00 14.99 0.00 1 0.00 0.00 _dl_important_hwcaps
0.00 14.99 0.00 1 0.00 0.00 _dl_init_paths
0.00 14.99 0.00 1 0.00 0.00 _dl_mcount_wrapper_check
0.00 14.99 0.00 1 0.00 0.00 _dl_non_dynamic_init
0.00 14.99 0.00 1 0.00 0.00 _mcleanup
0.00 14.99 0.00 1 0.00 0.00 atexit
0.00 14.99 0.00 1 0.00 0.00 exit
0.00 14.99 0.00 1 0.00 0.00 fillin_rpath
0.00 14.99 0.00 1 0.00 0.00 init
0.00 14.99 0.00 1 0.00 14.99 main
0.00 14.99 0.00 1 0.00 0.00 memcpy
0.00 14.99 0.00 1 0.00 0.00 moncontrol
0.00 14.99 0.00 1 0.00 0.00 setitimer
0.00 14.99 0.00 1 0.00 0.00 sigaction
0.00 14.99 0.00 1 0.00 0.00 strnlen
0.00 14.99 0.00 1 0.00 0.00 strrchr
0.00 14.99 0.00 1 0.00 0.00 uname
--- flat profile ---
mmmmh, strange...?