forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

-pg gprof profiling library added to libc

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
gawd



Joined: 09 Feb 2005
Posts: 28
Location: Israel

PostPosted: Tue Oct 04, 2005 8:51 am    Post subject: -pg gprof profiling library added to libc Reply with quote

Hey,

Committed at revision 1222 is my latest patch, -pg profiling. Supports both caller->callee graph profiling, and sampling.

In order to get your code profiled, just add -pg to your EE_CFLAGS variable in your Makefile. That's all there's to it. But please read on before using this. Like on any other platform, the generated output file is only written when main() leaves. Either by normal exit, or by calling exit(). Which means you will have to terminate your program to get the output. Also, the output is always written to host:gmon.out.

The implementation of sampling uses either TIM0 or TIM1. By default it is TIM0, but it is changeable by a #define at the beginning of mcount_internal.c. Please make sure you're not using the same timer as mcount.

An example is found under libc/samples/prof. It's a simple example(/test) that shows a function called loops_10_times being called 10 times(duh), and that function calls nested only 5 times. Another function, sleeping_beauty is called, and it waits around 3 seconds worth of hsync (see output below, 2.96 seconds).

One last thing, if you want to profile the entire libc, go into its Makefile and look for a commented "-pg".

Running the sample will yield the following output (portion of it):

Code:

Flat profile:

Each sample counts as 0.001 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name   
100.00      2.96     2.96        1     2.96     2.96  sleeping_beauty
  0.00      2.96     0.00       10     0.00     0.00  loops_10_times
  0.00      2.96     0.00        5     0.00     0.00  nested
  0.00      2.96     0.00        4     0.00     0.00  SifAddCmdHandler
  0.00      2.96     0.00        3     0.00     0.00  DIntr
  0.00      2.96     0.00        3     0.00     0.00  EIntr
  0.00      2.96     0.00        1     0.00     0.00  EnableDmac
  0.00      2.96     0.00        1     0.00     0.00  SifInitCmd
  0.00      2.96     0.00        1     0.00     0.00  SifInitRpc
  0.00      2.96     0.00        1     0.00     0.00  SifSendCmd
  0.00      2.96     0.00        1     0.00     0.00  _SifSendCmd
  0.00      2.96     0.00        1     0.00     0.00  _ps2sdk_alloc_init
  0.00      2.96     0.00        1     0.00     0.00  _ps2sdk_args_parse
  0.00      2.96     0.00        1     0.00     0.00  _ps2sdk_libc_deinit
  0.00      2.96     0.00        1     0.00     0.00  _ps2sdk_libc_init
  0.00      2.96     0.00        1     0.00     0.00  _ps2sdk_stdio_init
  0.00      2.96     0.00        1     0.00     0.00  _ps2sdk_stdlib_deinit
  0.00      2.96     0.00        1     0.00     0.00  _ps2sdk_stdlib_init
  0.00      2.96     0.00        1     0.00     0.00  chdir
  0.00      2.96     0.00        1     0.00     0.00  cleanup
  0.00      2.96     0.00        1     0.00     2.96  main



Hope somebody finds this useful. I have found many debug functions being called in the code that I'm working on, so, you never know :P

-- gawd 2005-10-03
[/i]
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TJ



Joined: 07 Jul 2005
Posts: 7

PostPosted: Fri Oct 14, 2005 3:26 pm    Post subject: Reply with quote

Hi gawd,

This is great! Exactly what I was after. Thanks so much for the effort!

// TJ
Back to top
View user's profile Send private message
happycoding



Joined: 22 Jan 2006
Posts: 31

PostPosted: Mon Feb 06, 2006 2:35 pm    Post subject: Reply with quote

Is it possible to port this into PSPSDK? It's exactly what I want in PSP! :P
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group