"#pragma profile" controls the generation of profiling code. This allows optionally including or excluding sections of source code to be profiled.
when #pragma profile = true, then profiling code is generated
when #pragma profile = false, then profiling code is not generated
__FB_OPTION_PROFILE__ is set to non-zero when #pragma profile = true
__FB_OPTION_PROFILE__ is set to zero when #pragma profile = false
I don't have an example for __FB_OPTION_PROFILE__, but it is used to detect at compile time if the current section of code is being compiled will have profiling code generated for it.
Consider this example and generating a call tree:
Code: Select all
#cmdline "-profgen fb"
#if __FB_PROFILE__
#include once "fbc-int/profile.bi"
fbc.ProfileSetOptions( fbc.PROFILE_OPTION_REPORT_CALLTREE )
#endif
sub A( byval n as integer )
sleep 100, 1
if( n > 0 ) then
A( n - 1 )
end if
end sub
A( 5 )
Code: Select all
Call Tree:
\- (main)
|- A
| |- A
| | |- A
| | | |- A
| | | | |- A
| | | | | |- A
| | | | | | \- SLEEP
| | | | | \- SLEEP
| | | | \- SLEEP
| | | \- SLEEP
| | \- SLEEP
| \- SLEEP
|- PROFILESETOPTIONS
\- FB___MAIN
Code: Select all
#cmdline "-profgen fb"
#if __FB_PROFILE__
#include once "fbc-int/profile.bi"
fbc.ProfileSetOptions( fbc.PROFILE_OPTION_REPORT_CALLTREE )
#endif
sub A( byval n as integer )
#pragma push(profile,false)
sleep 100, 1
#pragma pop(profile)
if( n > 0 ) then
A( n - 1 )
end if
end sub
A( 5 )
Code: Select all
Call Tree:
\- (main)
|- A
| \- A
| \- A
| \- A
| \- A
| \- A
|- PROFILESETOPTIONS
\- FB___MAIN