From 2b42f351f0bae35bb082d0ddfe79f8fdaef6f6b9 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Fri, 22 Feb 2013 09:37:01 +0100 Subject: [PATCH] DPL static block usage for profiling [Issue#] N/A [Bug] Refactoring to static block abstract which was aded in related change [Cause] N/A [Solution] Use added construction [Verification] Build repository with profiling. Run wrt-client. Assure no assert is thrown. This change needs merged: https://tizendev.org/gerrit/#/c/47415/ from wrt-commons Change-Id: I057a90b102962a50f856164cb4bd77dcece6118d --- src/profiling/profiling_util.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/profiling/profiling_util.cpp b/src/profiling/profiling_util.cpp index b8a08ef..cd94c0f 100644 --- a/src/profiling/profiling_util.cpp +++ b/src/profiling/profiling_util.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include namespace { const int PROFILING_OUTPUT_DESCRIPTOR = 3; @@ -110,21 +112,16 @@ void sigUsrHandler(int /*num*/) dumpStatistic(); } -int initialize(); - -const int i = initialize(); DPL::Mutex* m_mutex = NULL; -int initialize() +void initialize() { - (void)i; m_mutex = new DPL::Mutex; results.reserve(64 * 1024); signal(SIGUSR1, &sigUsrHandler); signal(SIGUSR2, &sigUsrHandler); LogDebug("Initialized profiling"); AddProfilingMeasurment("Profiling_Started"); - return 1; } std::string GetFormattedTime() @@ -149,6 +146,7 @@ std::string GetFormattedTime() void AddStdoutProfilingMeasurment(const char* name, bool start) { + Assert(m_mutex != NULL); std::ostringstream output; output << "[" << GetFormattedTime() << "] [](): " << name << " "; output << (start ? "profiling##start" : "profiling##stop"); @@ -166,3 +164,9 @@ void AddProfilingMeasurment(const char* name, results.push_back( PacketResult(toULong(value), name, prefix, description)); } + +STATIC_BLOCK +{ + initialize(); +} + -- 2.7.4