Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Elliott Lee Newsgroups: scea.yaroze.programming.gnu_compiler Subject: Re: Timing Code Date: Mon, 13 Apr 1998 13:38:11 -0700 Organization: Cisco Systems Lines: 60 Message-ID: <353277B3.8404A338@netmagic.net> References: <6gllke$3684@scea> <352E6C2C.DACE5289@netmagic.net> <6grspj$36811@scea> Reply-To: tenchi@cisco.com NNTP-Posting-Host: dhcp-e-39-237.cisco.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.03 [en] (Win95; U) Robert Schutt wrote: > > Could you be a little more "basic" with your explanation. I'm > not terribly familiar with the Playstation architecture. I'm trying > to write several programs which demonstrate the features of > the R3000 architecture. ie. like instruction pipelining etc. > > I'm using the Playstation because I don't have access to a > MIPS chip other than in the Playstation. > > I want to time a block of code. Perhaps the actual time to > execute an add instruction on the architecture. > > Perhaps some C code would look like > > for (i = 0; i < 1000000; i++) > a = b + c; > > The times would probably come out somewhere in 5 -15 seconds. > By dividing the time by 1000000 I can get instruction times. > > I just basically want to get a beginning time and end time. > > Can you recommend a reference where I may be able to find > out about the vsync, etc. Do you still think this would satisfy > my problem. > > -rschutt@cs.colgate.edu [...] Hm... the last explanation was a little cryptic. What I was trying to do was demonstrate how, based on using 60 frames-per-sec, you could estimate the actual amount of time something took. :) To actually just time a section of code accurately, I only see 2 real posibilities: 1) get an R3000 CPU tech sheet from MIPS and see the values they have printed there. Of course, there will be variations due to Sony's modifications and heat problems (which PSXs are infamous for), but that should give you a general idea. 2) use the root counter. I believe there are a couple of counter functions for starting and then reading this internal counter. See the index of your Library Reference guide for StartRCnt(), GetRCnt(), ResetRCnt(). The only problem was that I didn't understand what the return value actually is. Maybe milliseconds? If you attempt to use vertical refresh interrupts as your timing mechanism, you will lose CPU cycles in the interrupt-handling process and give you errors. (You could minimize the error factor by running this test over a large period of time, like 100 million add operations...) Just some ideas, - e! tenchi@netmagic.net http://www.netmagic.net/~tenchi/yaroze/