Giter Club home page Giter Club logo

veprogames.github.io's People

Contributors

jwklong avatar veprogames avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

veprogames.github.io's Issues

Performance issue regarding uncached formatNumber calls

Using the dev tools benchmarker, I have noticed 4% of execution time that could be avoided. functions.js formatNumber is expensive and seems to be executed regularly by vue. This is because content-matter.js:39 is a function that calls formatNumber and is bind.ed in upgrade.js:32. From my reading of Vue's docs, quoted below, Vue regularly polls methods binded to HTML, however, it caches computed properties based off reactive dependencies - ie it only re-executes the function when upgrades.betterObjects.level or the currentNotation changes.

However, the difference is that computed properties are cached based on their reactive dependencies. A computed property will only re-evaluate when some of its reactive dependencies have changed. This means as long as betterObjects.level has not changed, multiple access to the getEffectDisplay computed property will immediately return the previously computed result without having to run the function again.

This also means the following computed property will never update, because currentNotation is not a reactive dependency:
Why do we need caching? Imagine we have an expensive computed property A, which requires looping through a huge Array and doing a lot of computations. Then we may have other computed properties that in turn depend on A. Without caching, we would be executing Aโ€™s getter many more times than necessary! In cases where you do not want caching, use a method instead.

The solution may be that the level will never increase past a number which can just be represented by a number without needing notation, or by transferring the method to a computed property with reactive dependencies. A different angle is making formatNumber more efficient, which may be able to be done using "Intl.NumberFormat.prototype.format()" as recommended by the MDN.

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.