Code Monkey home page Code Monkey logo

Comments (14)

zlsa avatar zlsa commented on July 29, 2024

I've never even attempted to optimize it. I'll work on it.

from atc.

joallard avatar joallard commented on July 29, 2024

Good job. I've tried profiling a little, but wasn't nearly proficient enough with the architecture to see an obivous fix. canvas_update_post() came up.

from atc.

zlsa avatar zlsa commented on July 29, 2024

That's where the entire radar view is drawn. There's no view culling yet. The current bottleneck is drawing the text for each airplane; if I have to, I'll move the text drawing to the DOM, but that's a pretty major change.

from atc.

zlsa avatar zlsa commented on July 29, 2024

I've vastly reduced redrawing in version 2.1.4; could you test again?

from atc.

jvt avatar jvt commented on July 29, 2024

@joallard What year is your MBA? I'm also playing on an Air and didn't notice any performance-related issues in the prior versions.

from atc.

joallard avatar joallard commented on July 29, 2024

2.1.4: CPU seems to have more breathing space. I think the regular speed has gotten slower though. Might be unrelated.

@jvt Late 2013.

from atc.

zlsa avatar zlsa commented on July 29, 2024

@joallard, aircraft speed shouldn't change; I just redraw the canvas once every 20 frames or so. They might jump visibly when on higher speed settings, though.

from atc.

joallard avatar joallard commented on July 29, 2024

It may very well just be my perception, caveat emptor, but it feels to me a little more jittery and slowish.

from atc.

glangford avatar glangford commented on July 29, 2024

A significant portion of the time to draw each aircraft - 60-80% using console.time() - is drawing the trailing position dots, not drawing the aircraft itself. This is because canvas_draw_aircraft() saves and restores context and recreates a custom fillStyle and a filled arc - for every single trailing dot for every visible aircraft. This is very slow. I will send a pull request with an idea for a faster method which is visually similar.

from atc.

glangford avatar glangford commented on July 29, 2024

The first picture is the existing aircraft trail, the second is a test of a much faster method (rectangles and fixed opacity).
current trails
fast trails fixed opacity

from atc.

glangford avatar glangford commented on July 29, 2024

And here is a picture of the fast method with variable opacity. Which is the best?
(EDIT: This can be drawn in 1/5 of the time compared to the current method)
fast trails variable opacity

from atc.

joallard avatar joallard commented on July 29, 2024

@glangford Nice. This last render looks really good!

from atc.

glangford avatar glangford commented on July 29, 2024

@joallard , @zlsa - With changes #131, #141, #149, #150 I can run now for an extended period without excessive heating or fan use (older Macbook Pro). If there are no objections, I propose this issue can be closed.

from atc.

joallard avatar joallard commented on July 29, 2024

I'm clocking in at 1.5% CPU usage. Good job.

from atc.

Related Issues (20)

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.