From d2fc61888990136454d2ad1bcd08fd02070e19a7 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Thu, 25 Feb 2016 11:40:59 +0900 Subject: [PATCH] Apply T-trace --- common/common.gyp | 1 + common/profiler.cc | 24 +++++++++++++++++++++--- common/profiler.h | 5 +++-- packaging/crosswalk-tizen.spec | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/common/common.gyp b/common/common.gyp index 9cbb6eb..f399892 100644 --- a/common/common.gyp +++ b/common/common.gyp @@ -53,6 +53,7 @@ 'wgt-manifest-handlers', 'pkgmgr-info', 'glib-2.0', + 'ttrace', ], }, 'direct_dependent_settings': { diff --git a/common/profiler.cc b/common/profiler.cc index e619f3c..0f63aa6 100644 --- a/common/profiler.cc +++ b/common/profiler.cc @@ -17,6 +17,7 @@ #include "common/profiler.h" #include +#include #include "common/logger.h" #include "common/string_utils.h" @@ -41,19 +42,36 @@ void PrintProfileLog(const char* func, const char* tag) { << func << ":" << tag; } -ScopeProfile::ScopeProfile(const char* step) : step_(step), expired_(false) { +ScopeProfile::ScopeProfile(const char* step, const bool isStep) + : step_(step), expired_(false), isStep_(isStep) { clock_gettime(CLOCK_REALTIME, &start_); PrintProfileLog(step, "START"); + + if(isStep_) + traceAsyncBegin(TTRACE_TAG_WEB, 0, "%s%s", "XWALK:", step_.c_str()); + else + traceBegin(TTRACE_TAG_WEB,"%s%s", "XWALK:", step_.c_str()); } ScopeProfile::~ScopeProfile() { - if (!expired_) + if (!expired_) { PrintProfileTime(step_.c_str(), start_); + + if(isStep_) + traceAsyncEnd(TTRACE_TAG_WEB, 0, "%s%s", "XWALK:", step_.c_str()); + else + traceEnd(TTRACE_TAG_WEB); + } } void ScopeProfile::Reset() { clock_gettime(CLOCK_REALTIME, &start_); PrintProfileLog(step_.c_str(), "START-updated"); + + if(isStep_) + traceAsyncEnd(TTRACE_TAG_WEB, 0, "%s%s", "XWALK:", step_.c_str()); + else + traceEnd(TTRACE_TAG_WEB); } void ScopeProfile::End() { @@ -73,7 +91,7 @@ StepProfile::~StepProfile() { } void StepProfile::Start(const char* step) { - map_[step].reset(new ScopeProfile(step)); + map_[step].reset(new ScopeProfile(step, true)); } void StepProfile::End(const char* step) { diff --git a/common/profiler.h b/common/profiler.h index 51dd908..663ba6b 100644 --- a/common/profiler.h +++ b/common/profiler.h @@ -33,7 +33,7 @@ void PrintProfileLog(const char* func, const char* tag); class ScopeProfile { public: - explicit ScopeProfile(const char* step); + explicit ScopeProfile(const char* step, const bool isStep); ~ScopeProfile(); void Reset(); void End(); @@ -41,6 +41,7 @@ class ScopeProfile { std::string step_; struct timespec start_; bool expired_; + bool isStep_; }; class StepProfile { @@ -59,7 +60,7 @@ class StepProfile { } // namespace common #define SCOPE_PROFILE() \ - common::ScopeProfile __profile(__FUNCTION__); + common::ScopeProfile __profile(__FUNCTION__, false); #define STEP_PROFILE_START(x) \ common::StepProfile::GetInstance()->Start(x) diff --git a/packaging/crosswalk-tizen.spec b/packaging/crosswalk-tizen.spec index 96ec578..c3f64c0 100755 --- a/packaging/crosswalk-tizen.spec +++ b/packaging/crosswalk-tizen.spec @@ -42,6 +42,7 @@ BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(launchpad) +BuildRequires: pkgconfig(ttrace) Requires: /usr/bin/systemctl -- 2.7.4