Benchmark demos 06/271806/5
authorDavid Steele <david.steele@samsung.com>
Tue, 1 Mar 2022 18:51:06 +0000 (18:51 +0000)
committerDavid Steele <david.steele@samsung.com>
Thu, 10 Mar 2022 11:13:19 +0000 (11:13 +0000)
Change-Id: I4939b198338127fe7eb84816f1f5b23e198c74ad

com.samsung.dali-demo.xml
examples/cv-benchmark/color-visual-example.cpp [new file with mode: 0644]
examples/iv-benchmark/image-visual-benchmark.cpp [new file with mode: 0644]
examples/tl-benchmark/text-label-benchmark.cpp [new file with mode: 0644]

index 85fbc88..bfc1f6e 100644 (file)
        <ui-application appid="color-visual.example" exec="/usr/apps/com.samsung.dali-demo/bin/color-visual.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Color Visual</label>
        </ui-application>
+       <ui-application appid="cv-benchmark.example" exec="/usr/apps/com.samsung.dali-demo/bin/cv-benchmark.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>CV Benchmark</label>
+       </ui-application>
+       <ui-application appid="iv-benchmark.example" exec="/usr/apps/com.samsung.dali-demo/bin/iv-benchmark.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>IV Benchmark</label>
+       </ui-application>
+       <ui-application appid="tl-benchmark.example" exec="/usr/apps/com.samsung.dali-demo/bin/tl-benchmark.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>TL Benchmark</label>
+       </ui-application>
        <ui-application appid="compressed-texture-formats.example" exec="/usr/apps/com.samsung.dali-demo/bin/compressed-texture-formats.example" nodisplay="true" multiple="false" taskmanage="true" type="c++app">
                <label>Compressed Texture Formats</label>
        </ui-application>
diff --git a/examples/cv-benchmark/color-visual-example.cpp b/examples/cv-benchmark/color-visual-example.cpp
new file mode 100644 (file)
index 0000000..af9b8d5
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
+#include <dali/integration-api/debug.h>
+
+#include <dali/devel-api/adaptor-framework/performance-logger.h>
+
+#include <chrono>
+#include <list>
+#include <thread>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+} // namespace
+
+// This example shows the blur radius property of the color visual and animates it.
+//
+class ColorVisualExample : public ConnectionTracker
+{
+public:
+  ColorVisualExample(Application& application)
+  : mApplication(application)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
+  }
+
+  ~ColorVisualExample()
+  {
+    // Nothing to do here;
+  }
+
+  Window             window;
+  Timer              timer;
+  std::list<Control> list;
+  const int          n        = 20;
+  const int          m        = 20;
+  const int          duration = 100; // miliseconds.
+
+  PerformanceLogger customLoopLogger;
+  PerformanceLogger customNew1Logger;
+  PerformanceLogger customColorLogger;
+
+  // The Init signal is received once (only) during the Application lifetime
+  void Create(Application& application)
+  {
+    StyleManager instance = StyleManager::Get();
+    window                = application.GetWindow();
+    window.SetBackgroundColor(Color::WHITE);
+
+    timer = Timer::New(duration);
+    timer.TickSignal().Connect(this, &ColorVisualExample::OnTick);
+    timer.Start();
+
+    customLoopLogger  = PerformanceLogger::New("20Controls");
+    customNew1Logger  = PerformanceLogger::New("1_New");
+    customColorLogger = PerformanceLogger::New("2_SetBG");
+
+    customLoopLogger.EnableLogging(true);
+    customNew1Logger.EnableLogging(true);
+    customColorLogger.EnableLogging(true);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &ColorVisualExample::OnKeyEvent);
+  }
+
+  bool OnTick()
+  {
+    float width  = (float)window.GetSize().GetWidth() / m;
+    float height = (float)window.GetSize().GetHeight() / n;
+
+    int i = n - 1;
+    {
+      customLoopLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      Control rawView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
+      customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+      customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      rawView.SetBackgroundColor(Color::BLUE);
+      customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+      rawView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+      rawView[Actor::Property::ANCHOR_POINT]  = AnchorPoint::TOP_LEFT;
+      rawView[Actor::Property::SIZE]          = Vector2((float)window.GetSize().GetWidth(), height);
+      rawView[Actor::Property::POSITION]      = Vector2(0.0f, height * i);
+
+      for(int j = 0; j < m; j++)
+      {
+        Control bgView;
+        customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+        {
+          bgView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
+        }
+        customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+        customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+        bgView.SetBackgroundColor(Color::CRIMSON);
+        customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+        bgView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+        bgView[Actor::Property::ANCHOR_POINT]  = AnchorPoint::TOP_LEFT;
+        bgView[Actor::Property::SIZE]          = Vector2(width * 0.9f, height * 0.9f);
+        bgView[Actor::Property::POSITION]      = Vector2(width * j + width * 0.05f, height * 0.05f);
+        rawView.Add(bgView);
+      }
+      customLoopLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+      window.GetRootLayer().Add(rawView);
+      list.push_back(rawView);
+
+      Animation animation = Animation::New(duration * 0.001f * n);
+      animation.AnimateTo(Property(rawView, Actor::Property::POSITION_Y), -height);
+      animation.Play();
+
+      while((int)list.size() > n)
+      {
+        list.front().Unparent();
+        list.pop_front();
+      }
+    }
+
+    return true;
+  }
+
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.GetState() == KeyEvent::DOWN)
+    {
+      if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
+      {
+        timer.Stop();
+        list.clear();
+        mApplication.Quit();
+      }
+    }
+  }
+
+private:
+  Application& mApplication;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application        application = Application::New(&argc, &argv);
+  ColorVisualExample test(application);
+  application.MainLoop();
+  return 0;
+}
diff --git a/examples/iv-benchmark/image-visual-benchmark.cpp b/examples/iv-benchmark/image-visual-benchmark.cpp
new file mode 100644 (file)
index 0000000..cd6db40
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
+#include <dali/integration-api/debug.h>
+
+#include <dali/devel-api/adaptor-framework/performance-logger.h>
+
+#include <chrono>
+#include <list>
+#include <thread>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+} // namespace
+
+// This example shows the blur radius property of the color visual and animates it.
+//
+class ColorVisualExample : public ConnectionTracker
+{
+public:
+  ColorVisualExample(Application& application)
+  : mApplication(application)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
+  }
+
+  ~ColorVisualExample()
+  {
+    // Nothing to do here;
+  }
+
+  Window             window;
+  Timer              timer;
+  std::list<Control> list;
+  const int          n        = 20;
+  const int          m        = 20;
+  const int          duration = 100; // miliseconds.
+
+  PerformanceLogger customLoopLogger;
+  PerformanceLogger customNew1Logger;
+  PerformanceLogger customColorLogger;
+
+  // The Init signal is received once (only) during the Application lifetime
+  void Create(Application& application)
+  {
+    StyleManager instance = StyleManager::Get();
+    window                = application.GetWindow();
+    window.SetBackgroundColor(Color::WHITE);
+
+    timer = Timer::New(duration);
+    timer.TickSignal().Connect(this, &ColorVisualExample::OnTick);
+    timer.Start();
+
+    customLoopLogger  = PerformanceLogger::New("20Controls");
+    customNew1Logger  = PerformanceLogger::New("1_New");
+    customColorLogger = PerformanceLogger::New("2_SetBG");
+
+    customLoopLogger.EnableLogging(true);
+    customNew1Logger.EnableLogging(true);
+    customColorLogger.EnableLogging(true);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &ColorVisualExample::OnKeyEvent);
+  }
+
+  bool OnTick()
+  {
+    float width  = (float)window.GetSize().GetWidth() / m;
+    float height = (float)window.GetSize().GetHeight() / n;
+
+    int i = n - 1;
+    {
+      customLoopLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      Control rawView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
+      customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+      customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      rawView.SetBackgroundColor(Color::BLUE);
+      customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+      rawView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+      rawView[Actor::Property::ANCHOR_POINT]  = AnchorPoint::TOP_LEFT;
+      rawView[Actor::Property::SIZE]          = Vector2((float)window.GetSize().GetWidth(), height);
+      rawView[Actor::Property::POSITION]      = Vector2(0.0f, height * i);
+
+      for(int j = 0; j < m; j++)
+      {
+        Control bgView;
+        customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+        {
+          bgView = ImageView::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS, DEMO_IMAGE_DIR "gallery-small-23.jpg");
+        }
+        customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+        customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+        bgView.SetBackgroundColor(Color::CRIMSON);
+        customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+        bgView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+        bgView[Actor::Property::ANCHOR_POINT]  = AnchorPoint::TOP_LEFT;
+        bgView[Actor::Property::SIZE]          = Vector2(width * 0.9f, height * 0.9f);
+        bgView[Actor::Property::POSITION]      = Vector2(width * j + width * 0.05f, height * 0.05f);
+        rawView.Add(bgView);
+      }
+      customLoopLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+      window.GetRootLayer().Add(rawView);
+      list.push_back(rawView);
+
+      Animation animation = Animation::New(duration * 0.001f * n);
+      animation.AnimateTo(Property(rawView, Actor::Property::POSITION_Y), -height);
+      animation.Play();
+
+      while((int)list.size() > n)
+      {
+        list.front().Unparent();
+        list.pop_front();
+      }
+    }
+
+    return true;
+  }
+
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.GetState() == KeyEvent::DOWN)
+    {
+      if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
+      {
+        timer.Stop();
+        list.clear();
+        mApplication.Quit();
+      }
+    }
+  }
+
+private:
+  Application& mApplication;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application        application = Application::New(&argc, &argv);
+  ColorVisualExample test(application);
+  application.MainLoop();
+  return 0;
+}
diff --git a/examples/tl-benchmark/text-label-benchmark.cpp b/examples/tl-benchmark/text-label-benchmark.cpp
new file mode 100644 (file)
index 0000000..e4a1a51
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
+#include <dali/integration-api/debug.h>
+
+#include <dali/devel-api/adaptor-framework/performance-logger.h>
+
+#include <chrono>
+#include <list>
+#include <thread>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+} // namespace
+
+// This example shows the blur radius property of the color visual and animates it.
+//
+class ColorVisualExample : public ConnectionTracker
+{
+public:
+  ColorVisualExample(Application& application)
+  : mApplication(application)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
+  }
+
+  ~ColorVisualExample()
+  {
+    // Nothing to do here;
+  }
+
+  Window             window;
+  Timer              timer;
+  std::list<Control> list;
+  const int          n        = 20;
+  const int          m        = 20;
+  const int          duration = 100; // miliseconds.
+
+  PerformanceLogger customLoopLogger;
+  PerformanceLogger customNew1Logger;
+  PerformanceLogger customColorLogger;
+
+  // The Init signal is received once (only) during the Application lifetime
+  void Create(Application& application)
+  {
+    StyleManager instance = StyleManager::Get();
+    window                = application.GetWindow();
+    window.SetBackgroundColor(Color::WHITE);
+
+    timer = Timer::New(duration);
+    timer.TickSignal().Connect(this, &ColorVisualExample::OnTick);
+    timer.Start();
+
+    customLoopLogger  = PerformanceLogger::New("20Controls");
+    customNew1Logger  = PerformanceLogger::New("1_New");
+    customColorLogger = PerformanceLogger::New("2_SetBG");
+
+    customLoopLogger.EnableLogging(true);
+    customNew1Logger.EnableLogging(true);
+    customColorLogger.EnableLogging(true);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &ColorVisualExample::OnKeyEvent);
+  }
+
+  bool OnTick()
+  {
+    float width  = (float)window.GetSize().GetWidth() / m;
+    float height = (float)window.GetSize().GetHeight() / n;
+
+    int i = n - 1;
+    {
+      customLoopLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      Control rawView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
+      customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+      customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+      rawView.SetBackgroundColor(Color::BLUE);
+      customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+      rawView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+      rawView[Actor::Property::ANCHOR_POINT]  = AnchorPoint::TOP_LEFT;
+      rawView[Actor::Property::SIZE]          = Vector2((float)window.GetSize().GetWidth(), height);
+      rawView[Actor::Property::POSITION]      = Vector2(0.0f, height * i);
+
+      for(int j = 0; j < m; j++)
+      {
+        Control bgView;
+        customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+        {
+          bgView                                  = TextLabel::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
+          bgView[TextLabel::Property::TEXT]       = "Hello, world!";
+          bgView[TextLabel::Property::POINT_SIZE] = 12;
+        }
+        customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+        customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
+        bgView.SetBackgroundColor(Color::CRIMSON);
+        customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+        bgView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+        bgView[Actor::Property::ANCHOR_POINT]  = AnchorPoint::TOP_LEFT;
+        bgView[Actor::Property::SIZE]          = Vector2(width * 0.9f, height * 0.9f);
+        bgView[Actor::Property::POSITION]      = Vector2(width * j + width * 0.05f, height * 0.05f);
+        rawView.Add(bgView);
+      }
+      customLoopLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
+
+      window.GetRootLayer().Add(rawView);
+      list.push_back(rawView);
+
+      Animation animation = Animation::New(duration * 0.001f * n);
+      animation.AnimateTo(Property(rawView, Actor::Property::POSITION_Y), -height);
+      animation.Play();
+
+      while((int)list.size() > n)
+      {
+        list.front().Unparent();
+        list.pop_front();
+      }
+    }
+
+    return true;
+  }
+
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.GetState() == KeyEvent::DOWN)
+    {
+      if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
+      {
+        timer.Stop();
+        list.clear();
+        mApplication.Quit();
+      }
+    }
+  }
+
+private:
+  Application& mApplication;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application        application = Application::New(&argc, &argv);
+  ColorVisualExample test(application);
+  application.MainLoop();
+  return 0;
+}