WSF
profiling::ProfilingSystem Class Reference

Scope guard, whose constructor starts the profiling system, and whose destructor stops the profiling system. More...

#include <ProfilingSystem.hpp>

Public Member Functions

 ProfilingSystem (const ProfilingSystemArguments &aArgs)
 Use command-line arguments, as they would be parsed by code that uses profiling, to start the profiling system.
 ~ProfilingSystem ()
 Finalize the global profiling hooks if they were initialized, and then unload the shared library containing the hooks.
 ProfilingSystem ()=delete
 ProfilingSystem (const ProfilingSystem &)=delete
ProfilingSystemoperator= (const ProfilingSystem &)=delete
 ProfilingSystem (ProfilingSystem &&)=delete
ProfilingSystemoperator= (ProfilingSystem &&)=delete

Detailed Description

Scope guard, whose constructor starts the profiling system, and whose destructor stops the profiling system.

This class is meant to be used with ProfilingRegion, which marks a scope of C++ code for profiling.

Always name the variable representing the ProfilingSystem instance. Don't just invoke the constructor without giving the variable a name. If you forget to name the variable, then the region will close right away, since the unnamed temporary object's destructor will be invoked at the end of the statement.

Warning
Do NOT use this at main scope! Always make sure the object is out of scope before main returns.
Please only have one instance of ProfilingSystem active at a time. Please also see the thread parallelism discussion in the documentation of ProfilingRegion.

Constructor & Destructor Documentation

◆ ProfilingSystem() [1/4]

profiling::ProfilingSystem::ProfilingSystem ( const ProfilingSystemArguments & aArgs)

Use command-line arguments, as they would be parsed by code that uses profiling, to start the profiling system.

Parameters
aArgsCommand-line arguments, as they would be parsed by code that uses profiling.
Precondition
Either aArgs.mProfilingLibraryPath.has_value() is false, or aArgs.mProfilingOutputDest.has_value() is true.

"Start the profiling system" means to call the function in the library that initializes it, thus preparing it for profiling. Once the profiling system is started, you may use profiling regions (see ProfilingRegion.hpp) and sections to profile regions of C++ code, as long as the ProfilingSystem object is in scope.

If aArgs.mProfilingOutputDest is not set (does not have a value), then profiling will not occur. You may still use profiling regions and sections, but they will have no effect.

If aArgs.mProfilingOutputDest is set (has a value), profiling will occur. In that case, if aArgs.mProfilingLibraryPath is not set (does not have a value), then profiling will use the AFPerf library of profiling hooks. This is the primary (default) library that AFSIM builds and installs. It's what you want if you don't know otherwise. If aArgs.mProfilingLibraryPath is set (has a value), then profiling will use the alternate library of profiling hooks. An alternate shared library of profiling hooks may be any shared library that implements the interface described in ProfilingHooks.hpp, and need not be built or installed by AFSIM.

References profiling::ProfilingSystemArguments::mProfilingLibraryPath, and profiling::ProfilingSystemArguments::mProfilingOutputDest.

Referenced by operator=(), operator=(), ProfilingSystem(), and ProfilingSystem().

◆ ~ProfilingSystem()

profiling::ProfilingSystem::~ProfilingSystem ( )

Finalize the global profiling hooks if they were initialized, and then unload the shared library containing the hooks.

Once this destructor has been invoked, you may no longer use profiling regions or sections.

Warning
Do not invoke this in an atexit handler. Doing so can cause segmentation violations or other errors, as any state in the shared library might become invalid by the time exit is called or main returns. It's important that the destructor be called before main returns.

◆ ProfilingSystem() [2/4]

profiling::ProfilingSystem::ProfilingSystem ( )
delete

◆ ProfilingSystem() [3/4]

profiling::ProfilingSystem::ProfilingSystem ( const ProfilingSystem & )
delete

References ProfilingSystem().

◆ ProfilingSystem() [4/4]

profiling::ProfilingSystem::ProfilingSystem ( ProfilingSystem && )
delete

References ProfilingSystem().

Member Function Documentation

◆ operator=() [1/2]

ProfilingSystem & profiling::ProfilingSystem::operator= ( const ProfilingSystem & )
delete

References ProfilingSystem().

◆ operator=() [2/2]

ProfilingSystem & profiling::ProfilingSystem::operator= ( ProfilingSystem && )
delete

References ProfilingSystem().


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved