From a97a963bb2647678cd484212b1824a6019972086 Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Thu, 19 May 2016 13:24:22 +0900 Subject: [PATCH] Improve profiler messages Print name of the namespace and the class in the profiler message --- common/profiler.cc | 18 +++++++++++++++--- common/profiler.h | 2 +- extensions/common/xwalk_extension_manager.cc | 1 + extensions/renderer/xwalk_extension_client.cc | 1 + .../renderer/xwalk_extension_renderer_controller.cc | 1 + extensions/renderer/xwalk_module_system.cc | 2 ++ runtime/renderer/injected_bundle.cc | 11 +++-------- 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/common/profiler.cc b/common/profiler.cc index 0f63aa6..a71e797 100644 --- a/common/profiler.cc +++ b/common/profiler.cc @@ -25,6 +25,7 @@ namespace common { namespace { + void PrintProfileTime(const char* step, const struct timespec& start) { struct timespec end; clock_gettime(CLOCK_REALTIME, &end); @@ -38,14 +39,25 @@ void PrintProfileTime(const char* step, const struct timespec& start) { } // namespace void PrintProfileLog(const char* func, const char* tag) { - LOGGER(DEBUG) << "[PROF] [" << utils::GetCurrentMilliSeconds() << "] " - << func << ":" << tag; + LOGGER_RAW(DLOG_DEBUG, LOGGER_TAG) + << "[PROF] [" << utils::GetCurrentMilliSeconds() << "] " + << func << ":" << tag; } ScopeProfile::ScopeProfile(const char* step, const bool isStep) : step_(step), expired_(false), isStep_(isStep) { clock_gettime(CLOCK_REALTIME, &start_); - PrintProfileLog(step, "START"); + + if (!isStep) { + // Remove return type and parameter info from __PRETTY_FUNCTION__ + int se = step_.find_first_of('('); + int ss = step_.find_last_of(' ', se) + 1; + if (ss < se) { + step_ = step_.substr(ss, se - ss); + } + } + + PrintProfileLog(step_.c_str(), "START"); if(isStep_) traceAsyncBegin(TTRACE_TAG_WEB, 0, "%s%s", "XWALK:", step_.c_str()); diff --git a/common/profiler.h b/common/profiler.h index 663ba6b..9b0c750 100644 --- a/common/profiler.h +++ b/common/profiler.h @@ -60,7 +60,7 @@ class StepProfile { } // namespace common #define SCOPE_PROFILE() \ - common::ScopeProfile __profile(__FUNCTION__, false); + common::ScopeProfile __profile(__PRETTY_FUNCTION__, false); #define STEP_PROFILE_START(x) \ common::StepProfile::GetInstance()->Start(x) diff --git a/extensions/common/xwalk_extension_manager.cc b/extensions/common/xwalk_extension_manager.cc index 1d3e50d..962c0ae 100644 --- a/extensions/common/xwalk_extension_manager.cc +++ b/extensions/common/xwalk_extension_manager.cc @@ -74,6 +74,7 @@ void XWalkExtensionManager::LoadExtensions(bool meta_only) { ext_pattern.append(kExtensionPrefix); ext_pattern.append("*"); ext_pattern.append(kExtensionSuffix); + StringSet files; { glob_t glob_result; diff --git a/extensions/renderer/xwalk_extension_client.cc b/extensions/renderer/xwalk_extension_client.cc index d38ec04..4cb5738 100644 --- a/extensions/renderer/xwalk_extension_client.cc +++ b/extensions/renderer/xwalk_extension_client.cc @@ -41,6 +41,7 @@ XWalkExtensionClient::~XWalkExtensionClient() { } void XWalkExtensionClient::Initialize() { + SCOPE_PROFILE(); if (!extension_apis_.empty()) { return; } diff --git a/extensions/renderer/xwalk_extension_renderer_controller.cc b/extensions/renderer/xwalk_extension_renderer_controller.cc index 384abbb..2c916ea 100644 --- a/extensions/renderer/xwalk_extension_renderer_controller.cc +++ b/extensions/renderer/xwalk_extension_renderer_controller.cc @@ -56,6 +56,7 @@ XWalkExtensionRendererController::~XWalkExtensionRendererController() { void XWalkExtensionRendererController::DidCreateScriptContext( v8::Handle context) { + SCOPE_PROFILE(); XWalkModuleSystem* module_system = new XWalkModuleSystem(context); XWalkModuleSystem::SetModuleSystemInContext( std::unique_ptr(module_system), context); diff --git a/extensions/renderer/xwalk_module_system.cc b/extensions/renderer/xwalk_module_system.cc index 5cd4453..43d9630 100644 --- a/extensions/renderer/xwalk_module_system.cc +++ b/extensions/renderer/xwalk_module_system.cc @@ -10,6 +10,7 @@ #include #include "common/logger.h" +#include "common/profiler.h" #include "extensions/renderer/xwalk_extension_module.h" namespace extensions { @@ -309,6 +310,7 @@ v8::Handle XWalkModuleSystem::RequireNative( } void XWalkModuleSystem::Initialize() { + SCOPE_PROFILE(); v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handle_scope(isolate); v8::Handle context = GetV8Context(); diff --git a/runtime/renderer/injected_bundle.cc b/runtime/renderer/injected_bundle.cc index fa9c972..467f9c0 100755 --- a/runtime/renderer/injected_bundle.cc +++ b/runtime/renderer/injected_bundle.cc @@ -86,7 +86,6 @@ class BundleGlobalData { extern "C" void DynamicSetWidgetInfo(const char* tizen_id) { SCOPE_PROFILE(); - LOGGER(DEBUG) << "InjectedBundle::DynamicSetWidgetInfo !!" << tizen_id; ecore_init(); runtime::BundleGlobalData::GetInstance()->Initialize(tizen_id); @@ -105,18 +104,15 @@ extern "C" void DynamicPluginStartSession(const char* tizen_id, extensions::XWalkModuleSystem::SetModuleSystemInContext( std::unique_ptr(), context); - LOGGER(DEBUG) << "InjectedBundle::DynamicPluginStartSession !!" << tizen_id; if (base_url == NULL || common::utils::StartsWith(base_url, "http")) { LOGGER(ERROR) << "External url not allowed plugin loading."; return; } - STEP_PROFILE_START("Initialize RuntimeIPCClient"); // Initialize RuntimeIPCClient extensions::RuntimeIPCClient* rc = extensions::RuntimeIPCClient::GetInstance(); rc->SetRoutingId(context, routing_handle); - STEP_PROFILE_END("Initialize RuntimeIPCClient"); extensions::XWalkExtensionRendererController& controller = extensions::XWalkExtensionRendererController::GetInstance(); @@ -125,8 +121,7 @@ extern "C" void DynamicPluginStartSession(const char* tizen_id, extern "C" void DynamicPluginStopSession( const char* tizen_id, v8::Handle context) { - LOGGER(DEBUG) << "InjectedBundle::DynamicPluginStopSession !!" << tizen_id; - + SCOPE_PROFILE(); extensions::XWalkExtensionRendererController& controller = extensions::XWalkExtensionRendererController::GetInstance(); controller.WillReleaseScriptContext(context); @@ -165,14 +160,14 @@ extern "C" void DynamicDatabaseAttach(int /*attach*/) { } extern "C" void DynamicOnIPCMessage(const Ewk_IPC_Wrt_Message_Data& data) { - LOGGER(DEBUG) << "InjectedBundle::DynamicOnIPCMessage !!"; + SCOPE_PROFILE(); extensions::XWalkExtensionRendererController& controller = extensions::XWalkExtensionRendererController::GetInstance(); controller.OnReceivedIPCMessage(&data); } extern "C" void DynamicPreloading() { - LOGGER(DEBUG) << "InjectedBundle::DynamicPreloading !!"; + SCOPE_PROFILE(); runtime::BundleGlobalData::GetInstance()->PreInitialize(); extensions::XWalkExtensionRendererController& controller = extensions::XWalkExtensionRendererController::GetInstance(); -- 2.7.4