From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 11575 invoked from network); 12 Jan 1999 03:41:54 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 12 Jan 1999 03:41:54 -0000 Received: from alphagen.wn.net (55-wn_pm3-2.wn.net [206.190.210.55]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id WAA18433 for ; Mon, 11 Jan 1999 22:20:14 -0500 Received: from wn.net (peterpan@localhost [127.0.0.1]) by alphagen.wn.net (8.8.7/8.8.7) with ESMTP id WAA01754 for ; Mon, 11 Jan 1999 22:20:06 -0500 Sender: peterpan@wn.net Message-ID: <369ABF66.FFFD67EE@wn.net> Date: Mon, 11 Jan 1999 22:20:06 -0500 From: Peter Petrakis X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.0-pre6 alpha) MIME-Version: 1.0 To: axp-list@redhat.com Subject: Re: rpcc References: <278e88a7.u10t12e.df8c-axp@amazing.ch> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 } > 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 Housewares..."