Commit bbe7b3c663977d95d1ad00d5cf9f158f02149b03

Authored by David Steele
1 parent 0b7ced82

Benchmark demos

Change-Id: I4939b198338127fe7eb84816f1f5b23e198c74ad
com.samsung.dali-demo.xml
... ... @@ -76,6 +76,15 @@
76 76 <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">
77 77 <label>Color Visual</label>
78 78 </ui-application>
  79 + <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">
  80 + <label>CV Benchmark</label>
  81 + </ui-application>
  82 + <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">
  83 + <label>IV Benchmark</label>
  84 + </ui-application>
  85 + <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">
  86 + <label>TL Benchmark</label>
  87 + </ui-application>
79 88 <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">
80 89 <label>Compressed Texture Formats</label>
81 90 </ui-application>
... ...
examples/cv-benchmark/color-visual-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +#include <dali-toolkit/dali-toolkit.h>
  19 +#include <dali-toolkit/devel-api/controls/control-devel.h>
  20 +#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
  21 +#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
  22 +#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
  23 +#include <dali/integration-api/debug.h>
  24 +
  25 +#include <dali/devel-api/adaptor-framework/performance-logger.h>
  26 +
  27 +#include <chrono>
  28 +#include <list>
  29 +#include <thread>
  30 +
  31 +using namespace Dali;
  32 +using namespace Dali::Toolkit;
  33 +
  34 +namespace
  35 +{
  36 +} // namespace
  37 +
  38 +// This example shows the blur radius property of the color visual and animates it.
  39 +//
  40 +class ColorVisualExample : public ConnectionTracker
  41 +{
  42 +public:
  43 + ColorVisualExample(Application& application)
  44 + : mApplication(application)
  45 + {
  46 + // Connect to the Application's Init signal
  47 + mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
  48 + }
  49 +
  50 + ~ColorVisualExample()
  51 + {
  52 + // Nothing to do here;
  53 + }
  54 +
  55 + Window window;
  56 + Timer timer;
  57 + std::list<Control> list;
  58 + const int n = 20;
  59 + const int m = 20;
  60 + const int duration = 100; // miliseconds.
  61 +
  62 + PerformanceLogger customLoopLogger;
  63 + PerformanceLogger customNew1Logger;
  64 + PerformanceLogger customColorLogger;
  65 +
  66 + // The Init signal is received once (only) during the Application lifetime
  67 + void Create(Application& application)
  68 + {
  69 + StyleManager instance = StyleManager::Get();
  70 + window = application.GetWindow();
  71 + window.SetBackgroundColor(Color::WHITE);
  72 +
  73 + timer = Timer::New(duration);
  74 + timer.TickSignal().Connect(this, &ColorVisualExample::OnTick);
  75 + timer.Start();
  76 +
  77 + customLoopLogger = PerformanceLogger::New("20Controls");
  78 + customNew1Logger = PerformanceLogger::New("1_New");
  79 + customColorLogger = PerformanceLogger::New("2_SetBG");
  80 +
  81 + customLoopLogger.EnableLogging(true);
  82 + customNew1Logger.EnableLogging(true);
  83 + customColorLogger.EnableLogging(true);
  84 +
  85 + // Respond to key events
  86 + window.KeyEventSignal().Connect(this, &ColorVisualExample::OnKeyEvent);
  87 + }
  88 +
  89 + bool OnTick()
  90 + {
  91 + float width = (float)window.GetSize().GetWidth() / m;
  92 + float height = (float)window.GetSize().GetHeight() / n;
  93 +
  94 + int i = n - 1;
  95 + {
  96 + customLoopLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  97 + customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  98 + Control rawView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
  99 + customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  100 +
  101 + customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  102 + rawView.SetBackgroundColor(Color::BLUE);
  103 + customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  104 + rawView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
  105 + rawView[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
  106 + rawView[Actor::Property::SIZE] = Vector2((float)window.GetSize().GetWidth(), height);
  107 + rawView[Actor::Property::POSITION] = Vector2(0.0f, height * i);
  108 +
  109 + for(int j = 0; j < m; j++)
  110 + {
  111 + Control bgView;
  112 + customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  113 + {
  114 + bgView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
  115 + }
  116 + customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  117 +
  118 + customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  119 + bgView.SetBackgroundColor(Color::CRIMSON);
  120 + customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  121 + bgView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
  122 + bgView[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
  123 + bgView[Actor::Property::SIZE] = Vector2(width * 0.9f, height * 0.9f);
  124 + bgView[Actor::Property::POSITION] = Vector2(width * j + width * 0.05f, height * 0.05f);
  125 + rawView.Add(bgView);
  126 + }
  127 + customLoopLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  128 +
  129 + window.GetRootLayer().Add(rawView);
  130 + list.push_back(rawView);
  131 +
  132 + Animation animation = Animation::New(duration * 0.001f * n);
  133 + animation.AnimateTo(Property(rawView, Actor::Property::POSITION_Y), -height);
  134 + animation.Play();
  135 +
  136 + while((int)list.size() > n)
  137 + {
  138 + list.front().Unparent();
  139 + list.pop_front();
  140 + }
  141 + }
  142 +
  143 + return true;
  144 + }
  145 +
  146 + void OnKeyEvent(const KeyEvent& event)
  147 + {
  148 + if(event.GetState() == KeyEvent::DOWN)
  149 + {
  150 + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
  151 + {
  152 + timer.Stop();
  153 + list.clear();
  154 + mApplication.Quit();
  155 + }
  156 + }
  157 + }
  158 +
  159 +private:
  160 + Application& mApplication;
  161 +};
  162 +
  163 +int DALI_EXPORT_API main(int argc, char** argv)
  164 +{
  165 + Application application = Application::New(&argc, &argv);
  166 + ColorVisualExample test(application);
  167 + application.MainLoop();
  168 + return 0;
  169 +}
... ...
examples/iv-benchmark/image-visual-benchmark.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +#include <dali-toolkit/dali-toolkit.h>
  19 +#include <dali-toolkit/devel-api/controls/control-devel.h>
  20 +#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
  21 +#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
  22 +#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
  23 +#include <dali/integration-api/debug.h>
  24 +
  25 +#include <dali/devel-api/adaptor-framework/performance-logger.h>
  26 +
  27 +#include <chrono>
  28 +#include <list>
  29 +#include <thread>
  30 +
  31 +using namespace Dali;
  32 +using namespace Dali::Toolkit;
  33 +
  34 +namespace
  35 +{
  36 +} // namespace
  37 +
  38 +// This example shows the blur radius property of the color visual and animates it.
  39 +//
  40 +class ColorVisualExample : public ConnectionTracker
  41 +{
  42 +public:
  43 + ColorVisualExample(Application& application)
  44 + : mApplication(application)
  45 + {
  46 + // Connect to the Application's Init signal
  47 + mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
  48 + }
  49 +
  50 + ~ColorVisualExample()
  51 + {
  52 + // Nothing to do here;
  53 + }
  54 +
  55 + Window window;
  56 + Timer timer;
  57 + std::list<Control> list;
  58 + const int n = 20;
  59 + const int m = 20;
  60 + const int duration = 100; // miliseconds.
  61 +
  62 + PerformanceLogger customLoopLogger;
  63 + PerformanceLogger customNew1Logger;
  64 + PerformanceLogger customColorLogger;
  65 +
  66 + // The Init signal is received once (only) during the Application lifetime
  67 + void Create(Application& application)
  68 + {
  69 + StyleManager instance = StyleManager::Get();
  70 + window = application.GetWindow();
  71 + window.SetBackgroundColor(Color::WHITE);
  72 +
  73 + timer = Timer::New(duration);
  74 + timer.TickSignal().Connect(this, &ColorVisualExample::OnTick);
  75 + timer.Start();
  76 +
  77 + customLoopLogger = PerformanceLogger::New("20Controls");
  78 + customNew1Logger = PerformanceLogger::New("1_New");
  79 + customColorLogger = PerformanceLogger::New("2_SetBG");
  80 +
  81 + customLoopLogger.EnableLogging(true);
  82 + customNew1Logger.EnableLogging(true);
  83 + customColorLogger.EnableLogging(true);
  84 +
  85 + // Respond to key events
  86 + window.KeyEventSignal().Connect(this, &ColorVisualExample::OnKeyEvent);
  87 + }
  88 +
  89 + bool OnTick()
  90 + {
  91 + float width = (float)window.GetSize().GetWidth() / m;
  92 + float height = (float)window.GetSize().GetHeight() / n;
  93 +
  94 + int i = n - 1;
  95 + {
  96 + customLoopLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  97 + customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  98 + Control rawView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
  99 + customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  100 +
  101 + customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  102 + rawView.SetBackgroundColor(Color::BLUE);
  103 + customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  104 + rawView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
  105 + rawView[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
  106 + rawView[Actor::Property::SIZE] = Vector2((float)window.GetSize().GetWidth(), height);
  107 + rawView[Actor::Property::POSITION] = Vector2(0.0f, height * i);
  108 +
  109 + for(int j = 0; j < m; j++)
  110 + {
  111 + Control bgView;
  112 + customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  113 + {
  114 + bgView = ImageView::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS, DEMO_IMAGE_DIR "gallery-small-23.jpg");
  115 + }
  116 + customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  117 +
  118 + customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  119 + bgView.SetBackgroundColor(Color::CRIMSON);
  120 + customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  121 + bgView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
  122 + bgView[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
  123 + bgView[Actor::Property::SIZE] = Vector2(width * 0.9f, height * 0.9f);
  124 + bgView[Actor::Property::POSITION] = Vector2(width * j + width * 0.05f, height * 0.05f);
  125 + rawView.Add(bgView);
  126 + }
  127 + customLoopLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  128 +
  129 + window.GetRootLayer().Add(rawView);
  130 + list.push_back(rawView);
  131 +
  132 + Animation animation = Animation::New(duration * 0.001f * n);
  133 + animation.AnimateTo(Property(rawView, Actor::Property::POSITION_Y), -height);
  134 + animation.Play();
  135 +
  136 + while((int)list.size() > n)
  137 + {
  138 + list.front().Unparent();
  139 + list.pop_front();
  140 + }
  141 + }
  142 +
  143 + return true;
  144 + }
  145 +
  146 + void OnKeyEvent(const KeyEvent& event)
  147 + {
  148 + if(event.GetState() == KeyEvent::DOWN)
  149 + {
  150 + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
  151 + {
  152 + timer.Stop();
  153 + list.clear();
  154 + mApplication.Quit();
  155 + }
  156 + }
  157 + }
  158 +
  159 +private:
  160 + Application& mApplication;
  161 +};
  162 +
  163 +int DALI_EXPORT_API main(int argc, char** argv)
  164 +{
  165 + Application application = Application::New(&argc, &argv);
  166 + ColorVisualExample test(application);
  167 + application.MainLoop();
  168 + return 0;
  169 +}
... ...
examples/tl-benchmark/text-label-benchmark.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +#include <dali-toolkit/dali-toolkit.h>
  19 +#include <dali-toolkit/devel-api/controls/control-devel.h>
  20 +#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
  21 +#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
  22 +#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
  23 +#include <dali/integration-api/debug.h>
  24 +
  25 +#include <dali/devel-api/adaptor-framework/performance-logger.h>
  26 +
  27 +#include <chrono>
  28 +#include <list>
  29 +#include <thread>
  30 +
  31 +using namespace Dali;
  32 +using namespace Dali::Toolkit;
  33 +
  34 +namespace
  35 +{
  36 +} // namespace
  37 +
  38 +// This example shows the blur radius property of the color visual and animates it.
  39 +//
  40 +class ColorVisualExample : public ConnectionTracker
  41 +{
  42 +public:
  43 + ColorVisualExample(Application& application)
  44 + : mApplication(application)
  45 + {
  46 + // Connect to the Application's Init signal
  47 + mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
  48 + }
  49 +
  50 + ~ColorVisualExample()
  51 + {
  52 + // Nothing to do here;
  53 + }
  54 +
  55 + Window window;
  56 + Timer timer;
  57 + std::list<Control> list;
  58 + const int n = 20;
  59 + const int m = 20;
  60 + const int duration = 100; // miliseconds.
  61 +
  62 + PerformanceLogger customLoopLogger;
  63 + PerformanceLogger customNew1Logger;
  64 + PerformanceLogger customColorLogger;
  65 +
  66 + // The Init signal is received once (only) during the Application lifetime
  67 + void Create(Application& application)
  68 + {
  69 + StyleManager instance = StyleManager::Get();
  70 + window = application.GetWindow();
  71 + window.SetBackgroundColor(Color::WHITE);
  72 +
  73 + timer = Timer::New(duration);
  74 + timer.TickSignal().Connect(this, &ColorVisualExample::OnTick);
  75 + timer.Start();
  76 +
  77 + customLoopLogger = PerformanceLogger::New("20Controls");
  78 + customNew1Logger = PerformanceLogger::New("1_New");
  79 + customColorLogger = PerformanceLogger::New("2_SetBG");
  80 +
  81 + customLoopLogger.EnableLogging(true);
  82 + customNew1Logger.EnableLogging(true);
  83 + customColorLogger.EnableLogging(true);
  84 +
  85 + // Respond to key events
  86 + window.KeyEventSignal().Connect(this, &ColorVisualExample::OnKeyEvent);
  87 + }
  88 +
  89 + bool OnTick()
  90 + {
  91 + float width = (float)window.GetSize().GetWidth() / m;
  92 + float height = (float)window.GetSize().GetHeight() / n;
  93 +
  94 + int i = n - 1;
  95 + {
  96 + customLoopLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  97 + customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  98 + Control rawView = Control::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
  99 + customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  100 +
  101 + customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  102 + rawView.SetBackgroundColor(Color::BLUE);
  103 + customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  104 + rawView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
  105 + rawView[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
  106 + rawView[Actor::Property::SIZE] = Vector2((float)window.GetSize().GetWidth(), height);
  107 + rawView[Actor::Property::POSITION] = Vector2(0.0f, height * i);
  108 +
  109 + for(int j = 0; j < m; j++)
  110 + {
  111 + Control bgView;
  112 + customNew1Logger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  113 + {
  114 + bgView = TextLabel::New(Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
  115 + bgView[TextLabel::Property::TEXT] = "Hello, world!";
  116 + bgView[TextLabel::Property::POINT_SIZE] = 12;
  117 + }
  118 + customNew1Logger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  119 +
  120 + customColorLogger.AddMarker(PerformanceLogger::Marker::START_EVENT);
  121 + bgView.SetBackgroundColor(Color::CRIMSON);
  122 + customColorLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  123 + bgView[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
  124 + bgView[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
  125 + bgView[Actor::Property::SIZE] = Vector2(width * 0.9f, height * 0.9f);
  126 + bgView[Actor::Property::POSITION] = Vector2(width * j + width * 0.05f, height * 0.05f);
  127 + rawView.Add(bgView);
  128 + }
  129 + customLoopLogger.AddMarker(PerformanceLogger::Marker::END_EVENT);
  130 +
  131 + window.GetRootLayer().Add(rawView);
  132 + list.push_back(rawView);
  133 +
  134 + Animation animation = Animation::New(duration * 0.001f * n);
  135 + animation.AnimateTo(Property(rawView, Actor::Property::POSITION_Y), -height);
  136 + animation.Play();
  137 +
  138 + while((int)list.size() > n)
  139 + {
  140 + list.front().Unparent();
  141 + list.pop_front();
  142 + }
  143 + }
  144 +
  145 + return true;
  146 + }
  147 +
  148 + void OnKeyEvent(const KeyEvent& event)
  149 + {
  150 + if(event.GetState() == KeyEvent::DOWN)
  151 + {
  152 + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
  153 + {
  154 + timer.Stop();
  155 + list.clear();
  156 + mApplication.Quit();
  157 + }
  158 + }
  159 + }
  160 +
  161 +private:
  162 + Application& mApplication;
  163 +};
  164 +
  165 +int DALI_EXPORT_API main(int argc, char** argv)
  166 +{
  167 + Application application = Application::New(&argc, &argv);
  168 + ColorVisualExample test(application);
  169 + application.MainLoop();
  170 + return 0;
  171 +}
... ...