Improve profiler messages
authorWonYoung Choi <wy80.choi@samsung.com>
Thu, 19 May 2016 04:24:22 +0000 (13:24 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 19 May 2016 04:24:22 +0000 (13:24 +0900)
Print name of the namespace and the class in the profiler message

common/profiler.cc
common/profiler.h
extensions/common/xwalk_extension_manager.cc
extensions/renderer/xwalk_extension_client.cc
extensions/renderer/xwalk_extension_renderer_controller.cc
extensions/renderer/xwalk_module_system.cc
runtime/renderer/injected_bundle.cc

index 0f63aa6a31cf2bd6ba34732ccc82dc3e9574fc9d..a71e7970124439ed3f448801e55df31819b5398c 100644 (file)
@@ -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());
index 663ba6b1f876e68098f4480b642e1d9b22fa3c8c..9b0c750b788116ca173ec5c3d55994a0c775f659 100644 (file)
@@ -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)
index 1d3e50d60feeec3db2e05894462823c47d46f137..962c0ae6a8927984ae362a5372ee18777b2e100c 100644 (file)
@@ -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;
index d38ec045eda7ca8dd42a6100cef8278402004f73..4cb5738a56b19c602f56c81cff2199a85c65dc48 100644 (file)
@@ -41,6 +41,7 @@ XWalkExtensionClient::~XWalkExtensionClient() {
 }
 
 void XWalkExtensionClient::Initialize() {
+  SCOPE_PROFILE();
   if (!extension_apis_.empty()) {
     return;
   }
index 384abbbf3e4a76e1b1a317aba15da3c1bb81414c..2c916eaf297e7e7fdf51bba85d1f72bfffe2def0 100644 (file)
@@ -56,6 +56,7 @@ XWalkExtensionRendererController::~XWalkExtensionRendererController() {
 
 void XWalkExtensionRendererController::DidCreateScriptContext(
     v8::Handle<v8::Context> context) {
+  SCOPE_PROFILE();
   XWalkModuleSystem* module_system = new XWalkModuleSystem(context);
   XWalkModuleSystem::SetModuleSystemInContext(
       std::unique_ptr<XWalkModuleSystem>(module_system), context);
index 5cd44538ec7b33a32e7c059bbb9d172f030da3a7..43d9630d9f21d946465902efcfdfa7009e7f55c9 100644 (file)
@@ -10,6 +10,7 @@
 #include <algorithm>
 
 #include "common/logger.h"
+#include "common/profiler.h"
 #include "extensions/renderer/xwalk_extension_module.h"
 
 namespace extensions {
@@ -309,6 +310,7 @@ v8::Handle<v8::Object> XWalkModuleSystem::RequireNative(
 }
 
 void XWalkModuleSystem::Initialize() {
+  SCOPE_PROFILE();
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
   v8::HandleScope handle_scope(isolate);
   v8::Handle<v8::Context> context = GetV8Context();
index fa9c972785ff3f7699f03a8c3c3654ab502a7c07..467f9c0c2d5ff4b1e3f4d8c17bd8b795d1bcb0eb 100755 (executable)
@@ -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<extensions::XWalkModuleSystem>(), 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<v8::Context> 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();