Giter Site home page Giter Site logo

Comments (6)

ScottRobbins avatar ScottRobbins commented on August 19, 2024

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.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

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.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

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.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

aaand I've been benchmarking on a Debug build 🤦‍♂️

from declarativelayout.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

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.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.