Comments (7)
I agree that the following code would be more graceful that with the copy, but I don't really see a reason for a separate theme manager to be created.
auto button1 = Button::create(filename, section);
auto button2 = Button::create(filename, section);
The extra step to create the theme manager looks unneeded to me, unless you have another reason for it other than performance. If performance is the only reason then I can just as well cache the theme file internally.
But I am planning to review the widget creating code again, so I will keep this idea in mind.
A theme manager could perhaps be useful to make all widgets depend on one theme so that the theme of all widgets can be changed with just one line of code.
But this is all going to be for next year.
from tgui.
Yeah, using a theme cache provides better performance without any interface changes, it is a great idea for doing such optimizations in minor versions.
from tgui.
I will do some tests tomorrow to see if the perfomance difference is really that big.
I am not planning to add a cache if the difference is hardly noticable.
from tgui.
How big the performance improves depends on how big theme files are and how often to create the widgets dynamically, so I think it is a MUST-DO feature for some special scene(like create large amount of widgets in a window without using copy)
from tgui.
I just did some speed tests, and the caching won't be needed to make recreating the widget faster compared to copying it.
The tests have been done with 16.000 widgets (10.000 widgets of each of the 16 used types).
The speed difference with the white-theme is expected since it doesn't load or parse any files.
- Creating widgets with built-in white theme: 6.25 seconds
- Creating widgets with black theme: 31 seconds
- Copying widgets: 36.5 second
So it looks like copying is even slower than recreating the widget. I will look for a reason later.
from tgui.
Ok, these numbers don't really represent much. Some widgets must be taking a lot more time than they should.
New test with 100.000 buttons:
Creating with White theme: 3.6 seconds
Creating with Black theme: 8 seconds
Copying: 2.7 seconds
from tgui.
Ok, caching seems to have a significant impact (much more than I expected).
I will be adding the caching in both v0.6.6 and v0.7-dev.
Again, for 100.000 buttons:
Copying buttons: 1.25s
Cached theme file: 3.5s
Section at beginning of file: 5.45s
Section at end of file: 14.3s
So I notice a few things:
- Copying is still more than twice as fast as reloading the button (nothing can be done about that)
- It takes only 0,02 to 0,05 milliseconds to create a button if one was already loaded before
- The 5.45s is equivalent with the 8s earlier. I am using a different version, but that means that the new callback system in v0.7-dev will make creating widgets slightly slower.
I am going to close this issue (once it is implemented) since I don't expect to be writing a ThemeManager soon and I already have another issue reminding me that the entire loading code should be reviewed.
Thanks for making the suggestion though, I never knew that parsing these theme files took so long.
PS: All times were measured in debug mode. When using TGUI it should be much faster.
from tgui.
Related Issues (20)
- Autocomplete support for EditBox HOT 2
- Can not input CJK words HOT 9
- Black background shown when changing window size HOT 4
- How to customize the window's title bar and frame HOT 2
- How to implement a polygon window HOT 2
- Hover style does not disappear when mouse moves out of the window HOT 6
- Add a 2d chart or rendering 3d data for TGUI? HOT 1
- Chinese support? HOT 5
- Focus Issues HOT 1
- [ANNOUNCE] The TGUI now distributed via MSYS2 on Windows HOT 1
- CMake fails to install pkg-config files HOT 2
- On macOS, Input Method Editors(IME) behavior seems incorrect. HOT 6
- How to use SDL2/3 backend with cmake `FetchContent` HOT 2
- [Question] How to compile my first example of TGUI ? HOT 13
- [Bug] Dead radio button text HOT 3
- [Bug] Tabs state after disabled tab click HOT 2
- FileDialog documentation needs clarification and maybe working examples HOT 4
- Is there a C binding? HOT 12
- Raylib backend? HOT 15
- Cannot delete widgets inside of the gui-builder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tgui.