Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Peter Petrakis <peterpan@wn.net>
To: axp-list@redhat.com
Subject: Re: rpcc
Date: Mon, 11 Jan 1999 22:20:06 -0500	[thread overview]
Message-ID: <369ABF66.FFFD67EE@wn.net> (raw)
In-Reply-To: 278e88a7.u10t12e.df8c-axp@amazing.ch

Do you know how to profile your code? Here's an example. Say I have a
single source file called hello.c and i want to find out what calls it
makes , how many times the calls are made, percent of time spent etc
etc. I do this at the command line.

gcc -p -o hello hello.c

The -p flag generates code sutible for the profiler and the "hello" is
the name of the binary executable. Now execute hello.

./hello

Hello World

Wow, fancy. Now to see how it spent it's time. do

gprof hello

And you'll get something like this 

Flat profile:

Each sample counts as 0.000976562 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
........

I hope this is has some use. BTW any good text on C will detail how to
do this.
I learned the from "A book on C" which you can find at amazon.com 

Peter P.

Christoph Dworzak wrote:
> 
> Hi
> 
> With some help from this list, I'm getting better
> with axp-asm :)
> 
> Now my next question is, how do I measure the speed
> of my code?
> 
> My test looks like this:
> 
> --------------------------------------------------------
> unsigned long c1, c2, ccm=~0UL, ccs=0, n;
> 
> 
> for (n=0; n<(1UL<<19); n++){
>     asm volatile("rpcc %0" : "=r"(c1) : : "memory");
>     core();
>     asm volatile("rpcc %0" : "=r"(c2) : : "memory");
>     c1 = (c1 + (c1<<32)) >> 32;
>     c2 = (c2 + (c2<<32)) >> 32;
>     c2 = (c2>c1) ? c2-c1 : c2+(1UL<<32)-c1;
>     ccs += c2;
>     if (c2<ccm) ccm = c2;
> }
> printf("\nMin=%ld Avg=%ld\n\n", ccm, ccs/n;
> --------------------------------------------------------
> 
> When I run this several times, I get strange results
> (see end of my mail)
> 
> Why does it take up to 50% longer sometimes? (it really
> does, checking with my wrist-watch.)
> 
> Of course I know, there are some task-switches or interupts,
> but I would expect, that at least one loop out of one million
> runs uninteruptet on full speed...
> 
> Has it something to do with alignment of the code in memory
> and if so, how could I place the code so it runs at full speed?
> 
> Bye
>  dworz
> 
> --------------------------------------------------------
> [dworz@really speed]# time ./speedtest
> 
> Min=6063 Avg=6552
> 
> 13.85user 0.00system 0:15.11elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (69major+14minor)pagefaults 0swaps
> [dworz@really speed]# time ./speedtest
> 
> Min=6065 Avg=6546
> 
> 13.84user 0.00system 0:15.54elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (69major+14minor)pagefaults 0swaps
> [dworz@really speed]# time ./speedtest
> 
> Min=7961 Avg=8975
> 
> 18.93user 0.00system 0:20.66elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (69major+14minor)pagefaults 0swaps
> [dworz@really speed]# time ./speedtest
> 
> Min=6063 Avg=6532
> 
> 13.80user 0.00system 0:15.52elapsed 88%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (69major+14minor)pagefaults 0swaps
> [dworz@really speed]# time ./speedtest
> 
> Min=7975 Avg=8970
> 
> 18.92user 0.00system 0:20.66elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (69major+14minor)pagefaults 0swaps
> [dworz@really speed]# time ./speedtest
> 
> Min=6062 Avg=6477
> 
> 13.69user 0.00system 0:14.96elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (69major+14minor)pagefaults 0swaps
> [dworz@really speed]# time ./speedtest
> 
> Min=6063 Avg=6520
> 
> 13.78user 0.00system 0:15.06elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (69major+14minor)pagefaults 0swaps
> --------------------------------------------------------
> 
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

-- 
STCC DEC Alpha Resource Page
http://math.stcc.mass.edu/petrakis
PeterPan@wn.net  AlphaGuy =)
"BLAM! Who the hell are you!? Name's Ash <click clock> Housewares..."


  reply	other threads:[~1999-01-12  3:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-12  3:55 rpcc Christoph Dworzak
1999-01-12  3:20 ` Peter Petrakis [this message]
1999-01-12  4:59 ` rpcc Richard Henderson
     [not found]   ` <rth@twiddle.net>
1999-01-12 16:59     ` rpcc Christoph Dworzak
1999-01-12 19:27       ` rpcc Richard Henderson
1999-01-12 21:06         ` rpcc Wes Bauske
1999-01-13  2:16           ` rpcc Richard Henderson
1999-01-14 16:17     ` Alpha 21264 Christoph Dworzak
1999-01-14 15:46       ` Greg Lindahl
1999-01-14 17:27       ` Richard Henderson
1999-10-24 15:04     ` patch_v2: (on Alpha) emulating missing instructions Christoph Dworzak
1999-10-25  9:47       ` Phil Carmody
  -- strict thread matches above, loose matches on Subject: below --
1999-01-13 14:10 Alpha 21264 Andy Almond
1999-01-13 16:36 ` Jeff Sturm
1999-01-14  6:50   ` Richard Henderson
1999-10-18 14:46 patch_v2: (on Alpha) emulating missing instructions Robert Harley
1999-10-18 15:31 ` Phil Carmody
1999-10-23 20:39   ` Richard Henderson
1999-10-21 16:23 ` patch_v3: emulating missing instructions on Alpha Luke Deller
1999-10-23 20:55   ` Richard Henderson
1999-10-24  0:28     ` Daniel Potts
1999-10-25  1:22     ` Luke Deller
1999-10-28 23:34       ` Richard Henderson
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox