Workspace 6.21.5
Classes | Namespaces | Macros | Functions
executiontimekeeper.h File Reference
#include <memory>
#include <QDataStream>
#include <QList>
#include <QObject>
#include <QThread>
#include <QUuid>
#include "Workspace/Application/LanguageUtils/stringhelpers.h"
#include "Workspace/Application/LanguageUtils/scopeguard.h"
#include "Workspace/DataExecution/Operations/operation.h"
#include "Workspace/DataExecution/Serialization/serialize.h"
#include "Workspace/api_workspace.h"
Include dependency graph for executiontimekeeper.h:
This graph shows which files directly or indirectly include this file:

Classes

class  ExecutionTimekeeper::Event
 Event to be passed around. More...
 
class  ExecutionTimekeeper
 This class is a singleton and receives all notifications about operations' execution. It then sends a signal notifying the event. Any component wishing to make use of the operations' execution events should connect to this singleton and watch for the signal. More...
 
class  ExecutionTimekeeper::Publisher
 Process that can publish their profiling data. More...
 

Namespaces

namespace  CSIRO
 Top level namespace for all Workspace code.
 
namespace  CSIRO::DataExecution
 Base workspace functionality not requiring a user interface.
 
namespace  CSIRO::Widgets
 This namespace contains support for widgets attached to workspace data objects.
 

Macros

#define WS_CODEBLOCK_PROFILE_EVENT_(tag, type, file, line, func)
 
#define WS_PROFILE(tag)   WS_PROFILE_(tag, __FILE__, __LINE__, __FUNCTION__)
 
#define WS_PROFILE_(tag, file, line, func)
 
#define WS_PROFILE_BEGIN(tag)   WS_PROFILE_BEGIN_(tag, __FILE__, __LINE__, __FUNCTION__)
 
#define WS_PROFILE_BEGIN_(tag, file, line, func)   WS_CODEBLOCK_PROFILE_EVENT_(tag, CSIRO::DataExecution::ExecutionTimekeeper::CodeBlockBegin, file, line, func)
 
#define WS_PROFILE_END(tag)   WS_PROFILE_END_(tag, __FILE__, __LINE__, __FUNCTION__)
 
#define WS_PROFILE_END_(tag, file, line, func)   WS_CODEBLOCK_PROFILE_EVENT_(tag, CSIRO::DataExecution::ExecutionTimekeeper::CodeBlockEnd, file, line, func)
 

Functions

QDataStream & operator<< (QDataStream &out, const ExecutionTimekeeper::Event &event)
 
QDataStream & operator<< (QDataStream &out, const ExecutionTimekeeper::Publisher &publisher)
 
QDataStream & operator>> (QDataStream &in, ExecutionTimekeeper::Event &event)
 
QDataStream & operator>> (QDataStream &in, ExecutionTimekeeper::Publisher &publisher)
 

Macro Definition Documentation

◆ WS_CODEBLOCK_PROFILE_EVENT_

#define WS_CODEBLOCK_PROFILE_EVENT_ (   tag,
  type,
  file,
  line,
  func 
)
Value:
constexpr const auto WS_CONCAT3(ws_profile_, line, _filename) = \
&file ":" #line[CSIRO::Application::getFileNameOffset(file)]; \
CSIRO::DataExecution::ExecutionTimekeeper::getInstance().logTimeEvent( \
(tag), \
(type), \
WS_CONCAT3(ws_profile_, line, _filename), \
(func))
@ CodeBlockObject
Definition: executiontimekeeper.h:139
constexpr size_t getFileNameOffset(const T(&str)[S], size_t i=S - 1)
Definition: stringhelpers.h:63
#define WS_CONCAT3(x, y, z)
Definition: stringhelpers.h:50
Parameters
tagQString equivilant to identify a codeblock
typeshould be either ExecutionTimekeeper::CodeBlockBegin or ExecutionTimekeeper::CodeBlockEnd
filefilename where the codeblock is located
lineline number of the codeblock
funcfunction that contains the codeblock

◆ WS_PROFILE

#define WS_PROFILE (   tag)    WS_PROFILE_(tag, __FILE__, __LINE__, __FUNCTION__)
Parameters
tagQString equivilant to identify a codeblock

Logs a pair of codeblock profiling events within the current code scope.

Sample usage from a real use case in Workspace: ``` bool InsertColumnIntoSqlTableImpl::execute() {

// ... omitting a few lines here.

SqlResultSet result; QString selectQuery = QString("SELECT * FROM %1") .arg(database.driver()->escapeIdentifier(tableName, QSqlDriver::TableName)); { WS_PROFILE(selectQuery); // A generated tag name. if (!result.exec(selectQuery, database) || result.lastError().isValid()) { logLine(LOG_ERROR, tr("Unable to execute query \"%1\".Details below: \n%2").arg(selectQuery).arg(result.lastError().text())); return false; } }

// ... omitting a few lines here.

// Profile a specified scope: { WS_PROFILE("fetchMore"); while (model.canFetchMore()) { model.fetchMore(); } }

// ... omitting a few lines here.

// Profile the rest of current scope. WS_PROFILE("set records");

// ... omitting a few lines here.

} ```

See also
WS_PROFILE_BEGIN, WS_PROFILE_END

◆ WS_PROFILE_

#define WS_PROFILE_ (   tag,
  file,
  line,
  func 
)
Value:
auto WS_CONCAT3(ws_profile_, line, _tag) = tag; \
auto WS_CONCAT3(ws_profile_, line, _func) = func; \
WS_CODEBLOCK_PROFILE_EVENT_( \
WS_CONCAT3(ws_profile_, line, _tag), \
file, \
line, \
WS_CONCAT3(ws_profile_, line, _func)); \
auto WS_CONCAT(ws_profile_, line) = CSIRO::Application::createScopeGuard([=] { \
WS_CODEBLOCK_PROFILE_EVENT_( \
WS_CONCAT3(ws_profile_, line, _tag), \
file, \
line, \
WS_CONCAT3(ws_profile_, line, _func)); \
})
@ CodeBlockEnd
Definition: executiontimekeeper.h:128
@ CodeBlockBegin
Definition: executiontimekeeper.h:127
ScopeGuard< Callable > createScopeGuard(Callable rollback)
Definition: scopeguard.h:143
#define WS_CONCAT(x, y)
Definition: stringhelpers.h:49
Parameters
tagQString equivilant to identify a codeblock
filefilename where the codeblock is located
lineline number of the codeblock
funcfunction that contains the codeblock

◆ WS_PROFILE_BEGIN

#define WS_PROFILE_BEGIN (   tag)    WS_PROFILE_BEGIN_(tag, __FILE__, __LINE__, __FUNCTION__)
Parameters
tagQString equivilant to identify a codeblock

Logs a beginning of a codeblock profiling event. Should pair up with a WS_PROFILE_END usually in the same scope of code.

See also
WS_PROFILE_END, WS_PROFILE

◆ WS_PROFILE_BEGIN_

#define WS_PROFILE_BEGIN_ (   tag,
  file,
  line,
  func 
)    WS_CODEBLOCK_PROFILE_EVENT_(tag, CSIRO::DataExecution::ExecutionTimekeeper::CodeBlockBegin, file, line, func)

◆ WS_PROFILE_END

#define WS_PROFILE_END (   tag)    WS_PROFILE_END_(tag, __FILE__, __LINE__, __FUNCTION__)
Parameters
tagQString equivilant to identify a codeblock

Logs an ending of a codeblock profiling event. Should pair up with a WS_PROFILE_BEGIN usually in the same scope of code.

See also
WS_PROFILE_BEGIN, WS_PROFILE

◆ WS_PROFILE_END_

#define WS_PROFILE_END_ (   tag,
  file,
  line,
  func 
)    WS_CODEBLOCK_PROFILE_EVENT_(tag, CSIRO::DataExecution::ExecutionTimekeeper::CodeBlockEnd, file, line, func)