Search code examples
androidperformancemodel-view-controllermvvmandroid-architecture-components

Is there any performance improvement if I use MVVM


I was checking about MVVM architecture. I am very interested to know if there is a very good performance improvement in Android app. I have gone through several blog post which are talking about the comparison between MVP and MVVM. They are talking about it based on the following factors,

  1. CPU Usage (MVVM has slight upper hand with MVP)
  2. Memory Usage (MVP is good)
  3. Execution time (MVVM is good)

Paper link: https://www.atlantis-press.com/proceedings/issat-20/125949769 https://ejurnal.stmik-budidarma.ac.id/index.php/mib/article/view/4545

MVVM again has some flaws if the project grows, it's hard to maintain it because ViewModel may bloat hence we should user clean architecture.

I am confused here,

I have a project which does not follow strict MVVM practices but it is working fine and maintainable but it's not properly testable. Should I move to strict MVVM + Clean Architecture ? I agree that after this my code will be well testable and stick to the official guidelines. Because if i do so then in future, it may be easy for me to adopt Android guidelines.

But again the question remains same: Is there any performance, memory improvement ? And if yes, they how. In above papers, Execution time is claimed to be good with MVVM but how !

If i am moving to MVVM+Clean architecture then will i get any performance improvement!


Solution

  • Is there any performance improvement if I use MVVM?

    Short answer: No.

    MVVM again has some flaws if the project grows, it's hard to maintain it because ViewModel may bloat hence we should user clean architecture.

    This is not a flaw of MVVM - this is a flaw of the developer that allows the ViewModel to bloat.

    I have a project which does not follow strict MVVM practices but it is working fine and maintainable but it's not properly testable.

    One could argue that an app that is not "properly testable" is not actually "maintanable", but, OK.

    Should I move to strict MVVM + Clean Architecture ?

    That is a wholly subjective question no one can answer for you. Is this what you want to spend you time on? Is there an actual benefit to doing so?

    But again the question remains same: Is there any performance, memory improvement ?

    Probably not. Any performance / memory improvement will be realized by optimizing code for performance and memory, not by the architecture pattern you follow.

    In above papers, Execution time is claimed to be good with MVVM but how !

    I only skimmed said papers, but I don't know how anyone could reasonably review and measure app performance based on architecture.

    If i am moving to MVVM+Clean architecture then will i get any performance improvement!

    Probably not. If you're having performance problems now, it's likely due to some business logic that can be optimized irrespective of whatever architecture pattern you happen to be following.