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 0f63aa6..a71e797 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 663ba6b..9b0c750 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 1d3e50d..962c0ae 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 d38ec04..4cb5738 100644 (file)
@@ -41,6 +41,7 @@ XWalkExtensionClient::~XWalkExtensionClient() {
 }
 
 void XWalkExtensionClient::Initialize() {
+  SCOPE_PROFILE();
   if (!extension_apis_.empty()) {
     return;
   }
index 384abbb..2c916ea 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 5cd4453..43d9630 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 fa9c972..467f9c0 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();