Benchmark app for test Rendering performance 24/322624/3
authorEunki Hong <eunkiki.hong@samsung.com>
Fri, 11 Apr 2025 15:10:34 +0000 (00:10 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 14 Apr 2025 01:33:26 +0000 (10:33 +0900)
Previous benchmark.example have some heavy-animations.

Let we make more simple scene, so we can focus on Rendering performance.

Change-Id: I37a2d22fbcab2555a17e8d3d85fb4257eac32878
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
com.samsung.dali-demo.xml
examples/benchmark-color/README.md [new file with mode: 0644]
examples/benchmark-color/benchmark-color.cpp [new file with mode: 0644]
resources/po/en_GB.po
resources/po/en_US.po
shared/dali-demo-strings.h
tests-reel/dali-tests-reel.cpp

index 7f8faf06ac2624179947da2e9c97f49791e6a36e..f684d2e7d20c58a09ee38ce4ef20a59c9791e3b3 100644 (file)
@@ -46,6 +46,9 @@
        <ui-application appid="benchmark-2dphysics.example" exec="/usr/apps/com.samsung.dali-demo/bin/benchmark-2dphysics.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Benchmark 2D Physics</label>
        </ui-application>
+       <ui-application appid="benchmark-color.example" exec="/usr/apps/com.samsung.dali-demo/bin/benchmark-color.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>Benchmark Color</label>
+       </ui-application>
        <ui-application appid="bezier-curve.example" exec="/usr/apps/com.samsung.dali-demo/bin/bezier-curve.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Alpha Function Curve</label>
        </ui-application>
diff --git a/examples/benchmark-color/README.md b/examples/benchmark-color/README.md
new file mode 100644 (file)
index 0000000..436f8ea
--- /dev/null
@@ -0,0 +1,18 @@
+# Color benchmark Example
+
+This is an example to test the performance of DALI for simple Toolkit::Control with background color.
+Create 1 rootView and `R`x`C` views with random background colors. And animate the rootView's Opacity from
+0.8f to 0.2f, So we could avoid optimazation case of full-opaque or full-transparent cases.
+Application will be quit after `D` milliseconds.
+
+Each values `R`, `C`, and `D` could be change by commandline
+See below usages.
+
+```shell
+$ ./benchmark-color.example // R = 50, C = 20, D = 60000 (== 1 minute)
+$ ./benchmark-color.example -r200 -c80 -d1000 // R = 200, C = 80, D = 1000 (== 1 seconds)
+```
+
+
+
+
diff --git a/examples/benchmark-color/benchmark-color.cpp b/examples/benchmark-color/benchmark-color.cpp
new file mode 100644 (file)
index 0000000..1aa3e21
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2025 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/dali.h>
+
+#include <dali/devel-api/common/stage.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+uint32_t gRows(50);
+uint32_t gColumns(20);
+uint32_t gRunningDurationMilliSeconds(60 * 1000); // 1 minutes
+} // namespace
+
+// Test application to check performance for rendering simple colors
+// -r NumberOfRows    (Modifies the number of rows per page)
+// -c NumberOfColumns (Modifies the number of columns per page)
+// -d RunningDurationMilliSeconds (Modifies the duration of the test in milliseconds. 0 means infinite)
+// For example:
+// $ ./benchmark-color.example -r200 -c800 -d60000
+
+//
+class BenchmarkColor : public ConnectionTracker
+{
+public:
+  BenchmarkColor(Application& application)
+  : mApplication(application),
+    mRows(gRows),
+    mColumns(gColumns),
+    mRunningDurationMilliSeconds(gRunningDurationMilliSeconds)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &BenchmarkColor::Create);
+  }
+
+  ~BenchmarkColor() = default;
+
+  // The Init signal is received once (only) during the Application lifetime
+  void Create(Application& application)
+  {
+    // Get a handle to the window
+    Window window = application.GetWindow();
+    window.SetBackgroundColor(Color::BLACK);
+    Vector2 windowSize = window.GetSize();
+
+    mSize = Vector3(windowSize.x / static_cast<float>(mColumns), windowSize.y / static_cast<float>(mRows), 0.0f);
+
+    // Respond to a click anywhere on the window
+    window.GetRootLayer().TouchedSignal().Connect(this, &BenchmarkColor::OnTouch);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &BenchmarkColor::OnKeyEvent);
+
+    mRootActor = Actor::New();
+    mRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+    mRootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+    mRootActor.SetProperty(Actor::Property::OPACITY, 0.8f); ///< Do not make it as 1.0f, to avoid full-opaque optimization.
+
+    for(auto i = 0u; i < mRows; ++i)
+    {
+      for(auto j = 0u; j < mColumns; ++j)
+      {
+        Control control = Control::New();
+        control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+        control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+        control.SetProperty(Actor::Property::POSITION, Vector3(j * mSize.x, i * mSize.y, 0.0f));
+        control.SetProperty(Actor::Property::SIZE, mSize);
+        control.SetProperty(Control::Property::BACKGROUND, Vector4(Random::Range(0.0f, 1.0f), Random::Range(0.0f, 1.0f), Random::Range(0.0f, 1.0f), 1.0f));
+
+        mRootActor.Add(control);
+      }
+    }
+
+    window.GetRootLayer().Add(mRootActor);
+
+    mAnimation = Animation::New(10.0f);
+    mAnimation.SetLooping(true);
+    mAnimation.AnimateTo(Property(mRootActor, Actor::Property::OPACITY), 0.2f); ///< Do not make it as 0.0f, to avoid full-transparent optimization.
+    mAnimation.Play();
+
+    if(mRunningDurationMilliSeconds > 0u)
+    {
+      Stage::GetCurrent().KeepRendering(mRunningDurationMilliSeconds / 1000.0f + 30.0f);
+      mTimer = Timer::New(mRunningDurationMilliSeconds);
+      mTimer.TickSignal().Connect(this, &BenchmarkColor::OnTimer);
+      mTimer.Start();
+    }
+  }
+
+  bool OnTimer()
+  {
+    mApplication.Quit();
+    return false; // Stop the timer
+  }
+
+  bool OnTouch(Actor actor, const TouchEvent& touch)
+  {
+    // quit the application
+    mApplication.Quit();
+    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))
+      {
+        mApplication.Quit();
+      }
+    }
+  }
+
+private:
+  Application& mApplication;
+
+  uint32_t mRows;
+  uint32_t mColumns;
+  uint32_t mRunningDurationMilliSeconds;
+
+  Vector3 mSize;
+
+  Actor     mRootActor;
+  Animation mAnimation;
+  Timer     mTimer;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application application = Application::New(&argc, &argv);
+
+  for(int i(1); i < argc; ++i)
+  {
+    std::string arg(argv[i]);
+    if(arg.compare(0, 2, "-r") == 0)
+    {
+      gRows = atoi(arg.substr(2, arg.size()).c_str());
+    }
+    else if(arg.compare(0, 2, "-c") == 0)
+    {
+      gColumns = atoi(arg.substr(2, arg.size()).c_str());
+    }
+    else if(arg.compare(0, 2, "-d") == 0)
+    {
+      gRunningDurationMilliSeconds = atoi(arg.substr(2, arg.size()).c_str());
+    }
+  }
+
+  BenchmarkColor test(application);
+  application.MainLoop();
+
+  return 0;
+}
index dd19789d180474b25e1139bea796af60462f58ae..75db038f1be9e2c73f5d64fe54fcf72e7bef0450 100755 (executable)
@@ -19,6 +19,9 @@ msgstr "ImageView Benchmark"
 msgid "DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS"
 msgstr "2D Physics Benchmark"
 
+msgid "DALI_DEMO_STR_TITLE_BENCHMARK_COLOR"
+msgstr "BackgroundColor Benchmark"
+
 msgid "DALI_DEMO_STR_TITLE_BEZIER_CURVE"
 msgstr "Bezier Curve"
 
index e9d948631c7c0ba9cfc96438b7c78bbda7f7f5db..9804df21abf899bdb405386af0b094fa9ab0fccc 100755 (executable)
@@ -19,6 +19,9 @@ msgstr "ImageView Benchmark"
 msgid "DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS"
 msgstr "2D Physics Benchmark"
 
+msgid "DALI_DEMO_STR_TITLE_BENCHMARK_COLOR"
+msgstr "BackgroundColor Benchmark"
+
 msgid "DALI_DEMO_STR_TITLE_BEZIER_CURVE"
 msgstr "Bezier Curve"
 
index deff8996b63cb7afd6dd8fa480f4470a64b261a7..c71151505b4aa6a20f0b16532ba02f032e558bd5 100644 (file)
@@ -42,6 +42,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_BASIC_LIGHT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BASIC_LIGHT")
 #define DALI_DEMO_STR_TITLE_BENCHMARK dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BENCHMARK")
 #define DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS")
+#define DALI_DEMO_STR_TITLE_BENCHMARK_COLOR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BENCHMARK_COLOR")
 #define DALI_DEMO_STR_TITLE_BEZIER_CURVE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BEZIER_CURVE")
 #define DALI_DEMO_STR_TITLE_BLOCKS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOCKS")
 #define DALI_DEMO_STR_TITLE_BLOOM_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOOM_VIEW")
@@ -172,6 +173,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_BASIC_LIGHT "Basic Light"
 #define DALI_DEMO_STR_TITLE_BENCHMARK "ImageView Benchmark"
 #define DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS "2D Physics Benchmark"
+#define DALI_DEMO_STR_TITLE_BENCHMARK_COLOR "BackgroundColor Benchmark"
 #define DALI_DEMO_STR_TITLE_BEZIER_CURVE "Alpha Function Bezier Curve"
 #define DALI_DEMO_STR_TITLE_BLOCKS "Blocks"
 #define DALI_DEMO_STR_TITLE_BLOOM_VIEW "Bloom"
index 257e2e249c7886f1f893e84a0d321a16a8a86a91..61f605c13662fe189f51e7242dfbcbca0e81f3e6 100644 (file)
@@ -39,6 +39,7 @@ int DALI_EXPORT_API main(int argc, char** argv)
 
   demo.AddExample(Example("benchmark.example", DALI_DEMO_STR_TITLE_BENCHMARK));
   demo.AddExample(Example("benchmark-2dphysics.example", DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS));
+  demo.AddExample(Example("benchmark-color.example", DALI_DEMO_STR_TITLE_BENCHMARK_COLOR));
   demo.AddExample(Example("camera-test.example", DALI_DEMO_STR_TITLE_CAMERA_TEST));
   demo.AddExample(Example("compressed-texture-formats.example", DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS));
   demo.AddExample(Example("homescreen-benchmark.example", DALI_DEMO_STR_TITLE_HOMESCREEN));