-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from fjtrujy/gprof_improvements
Some `gprof` improvements
- Loading branch information
Showing
13 changed files
with
424 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* PSP Software Development Kit - https://github.com/pspdev | ||
* ----------------------------------------------------------------------- | ||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details. | ||
* | ||
* pspprof.h - Prototypes for the profiler library | ||
* | ||
* Copyright (c) 2006 Urchin | ||
* | ||
*/ | ||
#ifndef __PSPPROF_H__ | ||
#define __PSPPROF_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
|
||
/** | ||
* Start the profiler. | ||
* If the profiler is already running, this function stop previous one, | ||
* and ignore the result. | ||
* Finally, it initializes a new profiler session. | ||
*/ | ||
__attribute__((__no_instrument_function__, __no_profile_instrument_function__)) | ||
void gprof_start(void); | ||
/** | ||
* Stop the profiler. | ||
* If the profiler is not running, this function does nothing. | ||
* @param filename The name of the file to write the profiling data to. | ||
* @param should_dump If 1, the profiling data will be written to the file. | ||
* If 0, the profiling data will be discarded. | ||
*/ | ||
__attribute__((__no_instrument_function__, __no_profile_instrument_function__)) | ||
void gprof_stop(const char* filename, int should_dump); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __PSPPROF_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
TARGET = gprofbasic | ||
OBJS = main.o | ||
|
||
INCDIR = | ||
CFLAGS = -O2 -Wall -pg -g | ||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti | ||
ASFLAGS = $(CFLAGS) | ||
|
||
LIBDIR = | ||
LDFLAGS = -pg -g | ||
|
||
EXTRA_TARGETS = EBOOT.PBP | ||
PSP_EBOOT_TITLE = GProf Basic Example | ||
|
||
PSPSDK=$(shell psp-config --pspsdk-path) | ||
include $(PSPSDK)/lib/build.mak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Sample program to show how to use the `gprof` feature. | ||
|
||
The requiremnts are quite easy, just adding `-g -pg` flags to the `CFLAGS` and `LDFLAGS` is enough to make things to work out of the box. | ||
|
||
Firstly execute your program, then once program ends it will automatically generates a `gmon.out` file at CWD level. | ||
|
||
In order to inspect the content of the generated file you need to use the `psp-gprof` binary. | ||
|
||
For instance, following the next syntax: | ||
``` | ||
psp-gprof -b {binary.elf} gmon.out | ||
``` | ||
|
||
like: | ||
``` | ||
psp-gprof -b gprofbasic.elf gmon.out | ||
``` | ||
|
||
|
||
It will show something like: | ||
``` | ||
Flat profile: | ||
Each sample counts as 0.001 seconds. | ||
% cumulative self self total | ||
time seconds seconds calls ms/call ms/call name | ||
95.98 0.17 0.17 104728 0.00 0.00 is_prime | ||
4.02 0.17 0.01 1 7.00 7.00 dummy_function | ||
0.00 0.17 0.00 1 0.00 174.00 main | ||
0.00 0.17 0.00 1 0.00 167.00 sum_of_square_roots | ||
Call graph | ||
granularity: each sample hit covers 2 byte(s) for 0.57% of 0.17 seconds | ||
index % time self children called name | ||
0.00 0.17 1/1 _main [2] | ||
[1] 100.0 0.00 0.17 1 main [1] | ||
0.00 0.17 1/1 sum_of_square_roots [4] | ||
0.01 0.00 1/1 dummy_function [5] | ||
----------------------------------------------- | ||
<spontaneous> | ||
[2] 100.0 0.00 0.17 _main [2] | ||
0.00 0.17 1/1 main [1] | ||
----------------------------------------------- | ||
0.17 0.00 104728/104728 sum_of_square_roots [4] | ||
[3] 96.0 0.17 0.00 104728 is_prime [3] | ||
----------------------------------------------- | ||
0.00 0.17 1/1 main [1] | ||
[4] 96.0 0.00 0.17 1 sum_of_square_roots [4] | ||
0.17 0.00 104728/104728 is_prime [3] | ||
----------------------------------------------- | ||
0.01 0.00 1/1 main [1] | ||
[5] 4.0 0.01 0.00 1 dummy_function [5] | ||
----------------------------------------------- | ||
Index by function name | ||
[5] dummy_function [1] main | ||
[3] is_prime [4] sum_of_square_roots | ||
``` | ||
|
||
Cheers |
Oops, something went wrong.