Comments (6)
With my README example (which is a bad example but readily available to start with), the framework with diffing takes ~1.2ms to do the diffing, and about 0.2ms for the layout pass.
Total about 1.4ms
from declarativelayout.
I changed the implementation to just deactivate all of the old constraints and activate the new ones
Without the layout pass included, the updateConstraints method now takes ~1.8ms
The layout pass itself takes ~0.2ms
total, about 2ms
This, however, still has all of the constraints wrapped, so maybe the not-diffing part will be faster if i don't do that
from declarativelayout.
It's not really any different when removing the constraint wrapping. the NSLayoutconstraint.activate
method must be the biggest bottleneck here that the larger number of constraints it has to deal with takes longer than doing the diffing and updating properties on constraints already there.
Which is interesting, I thought the bottleneck would be during the layout pass, but really it's whatever work autolayout has to do when you activate/deactivate constraints.
from declarativelayout.
aaand I've been benchmarking on a Debug build 🤦♂️
from declarativelayout.
Well after running in release, it doesn't help the removing all constraints and re-adding all very much. That time stays pretty consistent. Though the total time for the implemented constraint diffing drops the diffing time to ~0.75ms, so a total of 1ms.
For this scenario, doing the constraint diffing seems to be about 100% faster
from declarativelayout.
Increasing this now to 100 views instead of what's just in the READMe.
Total time current implementation: 1.7, 1.8ms, something like that
Total time for removing all constraints and re-adding: similar, 1.6, 1.7ms.
So they kind of evened out
Let's do it for 20 views (and so 20 constraints), much more like reality
Current: 1ms
Removing all/re-adding: 1.6ms
It seems that the constraint diffing performs significantly better for normal usage. As your constraint number increases the time to diff them will eventually be surpassed by deactivating/activating constraints it seems.
I'm not trying to solve for outliers, so this doesn't really bother me. However, there's definitely room for improvement with the constraint diffing
from declarativelayout.
Related Issues (16)
- Add documentation about layout component returns HOT 1
- README should specify all constraints passed to activate should be unactivated HOT 7
- Should be examples of using other autolayout DSLs HOT 1
- Should not have constraint issues when moving views out of UIStackView HOT 4
- Support layout guides HOT 2
- Test how this affects layout using layout framework benchmark HOT 1
- Consider how to avoid recalculating constraint diffs for everything when making a change HOT 1
- Add default view creation to component methods HOT 1
- Add unit tests
- One more round of optimizing HOT 6
- Allow specifying identifier for view HOT 1
- Consider how to get rid of all of the `component.` HOT 9
- Update to Swift 5 HOT 1
- Musings on how to make it easier to control the flow of data for updating your UI HOT 8
- Awaiting WWDC 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 declarativelayout.