Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

If you want the profiling results to be meaningful, you should use the optimization flags that you intend to use in production.use the optimization flags that you intend to use in production.

That said, you can tell most compilers to never inline specific functions. For example, if you use gcc you could mark your label functions with __attribute__((noinline)):

__attribute__((noinline)) int func()
{
    ...
}

(Other compilers usually provide similar extensions.) This should allow the label functions to show up in the profile even when optimizations are enabled. Keep in mind that the attribute is gcc-specific, so remove it once you're done profiling, or wrap it in a macro that evaluates to nothing if a different compiler is used.

Of course, if the inlining of these specific functions actually has a significant impact on performance, the profiling results might still not be fully representative.

If you want the profiling results to be meaningful, you should use the optimization flags that you intend to use in production.

That said, you can tell most compilers to never inline specific functions. For example, if you use gcc you could mark your label functions with __attribute__((noinline)):

__attribute__((noinline)) int func()
{
    ...
}

(Other compilers usually provide similar extensions.) This should allow the label functions to show up in the profile even when optimizations are enabled. Keep in mind that the attribute is gcc-specific, so remove it once you're done profiling, or wrap it in a macro that evaluates to nothing if a different compiler is used.

Of course, if the inlining of these specific functions actually has a significant impact on performance, the profiling results might still not be fully representative.

If you want the profiling results to be meaningful, you should use the optimization flags that you intend to use in production.

That said, you can tell most compilers to never inline specific functions. For example, if you use gcc you could mark your label functions with __attribute__((noinline)):

__attribute__((noinline)) int func()
{
    ...
}

(Other compilers usually provide similar extensions.) This should allow the label functions to show up in the profile even when optimizations are enabled. Keep in mind that the attribute is gcc-specific, so remove it once you're done profiling, or wrap it in a macro that evaluates to nothing if a different compiler is used.

Of course, if the inlining of these specific functions actually has a significant impact on performance, the profiling results might still not be fully representative.

Source Link
nomadictype
  • 1.7k
  • 1
  • 12
  • 7

If you want the profiling results to be meaningful, you should use the optimization flags that you intend to use in production.

That said, you can tell most compilers to never inline specific functions. For example, if you use gcc you could mark your label functions with __attribute__((noinline)):

__attribute__((noinline)) int func()
{
    ...
}

(Other compilers usually provide similar extensions.) This should allow the label functions to show up in the profile even when optimizations are enabled. Keep in mind that the attribute is gcc-specific, so remove it once you're done profiling, or wrap it in a macro that evaluates to nothing if a different compiler is used.

Of course, if the inlining of these specific functions actually has a significant impact on performance, the profiling results might still not be fully representative.