From: David Steele Date: Tue, 1 Mar 2022 18:51:06 +0000 (+0000) Subject: Benchmark demos X-Git-Tag: dali_2.1.13~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F271806%2F5;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Benchmark demos Change-Id: I4939b198338127fe7eb84816f1f5b23e198c74ad --- diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 85fbc88..bfc1f6e 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -76,6 +76,15 @@ + + + + + + + + + diff --git a/examples/cv-benchmark/color-visual-example.cpp b/examples/cv-benchmark/color-visual-example.cpp new file mode 100644 index 0000000..af9b8d5 --- /dev/null +++ b/examples/cv-benchmark/color-visual-example.cpp @@ -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 +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +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 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 index 0000000..cd6db40 --- /dev/null +++ b/examples/iv-benchmark/image-visual-benchmark.cpp @@ -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 +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +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 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 index 0000000..e4a1a51 --- /dev/null +++ b/examples/tl-benchmark/text-label-benchmark.cpp @@ -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 +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +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 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; +}