Add trace logs to check performance 26/283126/2
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 18 Oct 2022 10:09:30 +0000 (19:09 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Thu, 20 Oct 2022 06:00:00 +0000 (15:00 +0900)
Change-Id: I72023f9d7d1d4c70c760df40162162fe48258807

dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/trace/tizen/trace-manager-impl-tizen.cpp
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp

index eedcbed..a9fbcfe 100644 (file)
@@ -34,6 +34,7 @@
 #include <dali/integration-api/input-options.h>
 #include <dali/integration-api/processor-interface.h>
 #include <dali/integration-api/profiling.h>
+#include <dali/integration-api/trace.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/events/wheel-event.h>
 #include <dali/public-api/object/any.h>
@@ -91,6 +92,7 @@ namespace
 {
 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
 } // unnamed namespace
 
 Dali::Adaptor* Adaptor::New(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode)
@@ -912,15 +914,11 @@ void Adaptor::ProcessCoreEvents()
       mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_START);
     }
 
-#if !defined(DALI_PROFILE_UBUNTU) && !defined(DALI_PROFILE_LIBUV_X11) && !defined(DALI_PROFILE_GLIB_X11)
-    DALI_LOG_RELEASE_INFO("Start ProcessEvents\n");
-#endif
+    DALI_TRACE_BEGIN(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
 
     mCore->ProcessEvents();
 
-#if !defined(DALI_PROFILE_UBUNTU) && !defined(DALI_PROFILE_LIBUV_X11) && !defined(DALI_PROFILE_GLIB_X11)
-    DALI_LOG_RELEASE_INFO("End ProcessEvents\n");
-#endif
+    DALI_TRACE_END(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
 
     if(mPerformanceInterface)
     {
index 41e8205..4a99c5a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  */
 
-// EXTERNAL INCLUDES
+// CLASS HEADER
 #include <dali/internal/trace/tizen/trace-manager-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
 #include <ttrace.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 
 namespace Dali
 {
@@ -27,9 +31,21 @@ namespace Internal
 {
 namespace Adaptor
 {
+namespace
+{
+const char* DALI_TRACE_ENABLE_PRINT_LOG_ENV = "DALI_TRACE_ENABLE_PRINT_LOG";
+static bool gTraceManagerEnablePrintLog     = false;
+
+} // namespace
+
 TraceManagerTizen::TraceManagerTizen(PerformanceInterface* performanceInterface)
 : TraceManager(performanceInterface)
 {
+  const char* enablePrintLog = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_TRACE_ENABLE_PRINT_LOG_ENV);
+  if(enablePrintLog && std::atoi(enablePrintLog) != 0)
+  {
+    gTraceManagerEnablePrintLog = true;
+  }
 }
 
 Dali::Integration::Trace::LogContextFunction TraceManagerTizen::GetLogContextFunction()
@@ -42,10 +58,20 @@ void TraceManagerTizen::LogContext(bool start, const char* tag)
   if(start)
   {
     traceBegin(TTRACE_TAG_GRAPHICS, tag);
+
+    if(gTraceManagerEnablePrintLog)
+    {
+      DALI_LOG_RELEASE_INFO("BEGIN: %s\n", tag);
+    }
   }
   else
   {
     traceEnd(TTRACE_TAG_GRAPHICS);
+
+    if(gTraceManagerEnablePrintLog)
+    {
+      DALI_LOG_RELEASE_INFO("END: %s\n", tag);
+    }
   }
 }
 
index 5d4cb1c..3317792 100644 (file)
@@ -363,7 +363,6 @@ void Window::SetPreferredOrientation(WindowOrientation orientation)
 
 WindowOrientation Window::GetPreferredOrientation()
 {
-  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
   WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
   return preferredOrientation;
 }
@@ -699,14 +698,14 @@ Dali::Window::WindowSize Window::GetSize() const
 void Window::SetPosition(Dali::Window::WindowPosition position)
 {
   PositionSize oldRect = mSurface->GetPositionSize();
-  int32_t newX = position.GetX();
-  int32_t newY = position.GetY();
+  int32_t      newX    = position.GetX();
+  int32_t      newY    = position.GetY();
 
   mWindowSurface->MoveResize(PositionSize(newX, newY, oldRect.width, oldRect.height));
 
   if((oldRect.x != newX) || (oldRect.y != newY))
   {
-    Dali::Window handle(this);
+    Dali::Window                 handle(this);
     Dali::Window::WindowPosition newPosition(newX, newY);
 
     DALI_LOG_RELEASE_INFO("send moved signal with new position: %d, %d\n", newPosition.GetX(), newPosition.GetY());
@@ -891,8 +890,8 @@ void Window::OnWindowRedrawRequest()
 
 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
 {
-  bool resized = false;
-  bool moved = false;
+  bool         resized = false;
+  bool         moved   = false;
   Dali::Window handle(this);
   PositionSize oldRect = mSurface->GetPositionSize();
 
@@ -921,8 +920,8 @@ void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
   {
     Uint16Pair newSize(newRect.width, newRect.height);
 
-    mWindowWidth   = newRect.width;
-    mWindowHeight  = newRect.height;
+    mWindowWidth  = newRect.width;
+    mWindowHeight = newRect.height;
 
     SurfaceResized();
 
@@ -1128,7 +1127,6 @@ Dali::Window Window::GetParent()
 
 WindowOrientation Window::GetCurrentOrientation() const
 {
-  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
   return ConvertToOrientation(mRotationAngle);
 }
 
index 8ddc82d..3594c91 100644 (file)
@@ -31,6 +31,7 @@
 // EXTERNAL_HEADERS
 #include <Ecore_Input.h>
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
 #include <dali/public-api/adaptor-framework/window-enumerations.h>
 #include <dali/public-api/events/mouse-button.h>
 #include <dali/public-api/object/any.h>
@@ -54,6 +55,8 @@ namespace
 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
 #endif
 
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
+
 const uint32_t     MAX_TIZEN_CLIENT_VERSION = 7;
 const unsigned int PRIMARY_TOUCH_BUTTON_ID  = 1;
 
@@ -1201,7 +1204,14 @@ void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
     std::string keyString("");
     std::string compose("");
 
-    DALI_LOG_RELEASE_INFO("OnKeyDown Start [%s]\n", keyName.c_str());
+#ifdef TRACE_ENABLED
+    std::ostringstream stream;
+    if(gTraceFilter->IsTraceEnabled())
+    {
+      stream << "DALI_ON_KEY_DOWN [" << keyName << "]\n";
+      DALI_TRACE_BEGIN(gTraceFilter, stream.str().c_str());
+    }
+#endif
 
     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
     if(keyEvent->compose)
@@ -1250,7 +1260,12 @@ void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
 
     mKeyEventSignal.Emit(keyEvent);
 
-    DALI_LOG_RELEASE_INFO("OnKeyDown End [%s]\n", keyName.c_str());
+#ifdef TRACE_ENABLED
+    if(gTraceFilter->IsTraceEnabled())
+    {
+      DALI_TRACE_END(gTraceFilter, stream.str().c_str());
+    }
+#endif
   }
 }
 
@@ -1274,7 +1289,14 @@ void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
     std::string keyString("");
     std::string compose("");
 
-    DALI_LOG_RELEASE_INFO("OnKeyUp Start [%s]\n", keyName.c_str());
+#ifdef TRACE_ENABLED
+    std::ostringstream stream;
+    if(gTraceFilter->IsTraceEnabled())
+    {
+      stream << "DALI_ON_KEY_UP [" << keyName << "]" << std::endl;
+      DALI_TRACE_BEGIN(gTraceFilter, stream.str().c_str());
+    }
+#endif
 
     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
     if(keyEvent->compose)
@@ -1323,7 +1345,12 @@ void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
 
     mKeyEventSignal.Emit(keyEvent);
 
-    DALI_LOG_RELEASE_INFO("OnKeyUp End [%s]\n", keyName.c_str());
+#ifdef TRACE_ENABLED
+    if(gTraceFilter->IsTraceEnabled())
+    {
+      DALI_TRACE_END(gTraceFilter, stream.str().c_str());
+    }
+#endif
   }
 }