Performance - code that never runs

● ARCHIVED · READ-ONLY
Started by ZephyrAM 11 posts View original ↗
  1. What I hope is a straightforward question that I've found it hard to search for:

    Does code that never runs (branches of an if statement that come out false for instance) affect the performance of the script/software?

    So if I were to write an if/else statement with... 12 branches let's say, but only two of them ever run in any one situation, do the other 10 negatively affect anything? Same question toward switch/case blocks or anything else with the same basis.

    Appreciate the input!

    ~ Zephyr
  2. Naw you should be fine, unless you have like thousands of branches then I wouldn't worry about it.

    Edit: Really even thousands would not effect performance unless the condition is somewhere near the end of the tree, it's more of a style and readability issue more than anything.
  3. no JavaScript executed from high down.
    all the conditions under the true are not tested.
    so if you get true condition at index 3 and you have 100 branch esle if in index.
    js will test only 3 branch, and all other 97 branch will not testing or evaluate.

    it same thing if you use switch
  4. Alright, I'd figured (and hoped) as much, but with all the performance issues Maker games can have, I'm trying to learn as many JS details as I can.
  5. The most important thing is being careful what you add to the scenes. Most performance hits come from having a bunch of bitmaps on the scene, and more importantly how many sprites are being added to the scene at once. For example if you need to add and remove a sprite numerous times really fast it may be better to simply add one sprite and change it's bitmap numerous times instead. To be fair though unless you are doing work in the update loop, or you're working in an area that is being rendered multiple times a frame then don't worry about performance, especially don't get caught up in micro optimizations(using for instead of forEach, apply instead of call, etc) unless it's one of those areas.
  6. So what you're saying is most optimization comes through how you use the MV editor. Unless coding a script is more efficient than using the Event's Conditional branch option?
  7. rmmv use eval for all script in editor.
    It more performance to call method from js than from rmmv script.
    Very very more fast !
    Make test on jsperf , you will see big difference.

    Example try eval a loop each 16 ms in rmmv editor .
    and try call a loop in pure js a each 16 ms
  8. Technically, the application parse time will scale with SLOC. But once it's running, it likely won't make much of a difference.

    Limit your use (direct or otherwise) of eval and I bet you a box of donuts it'll solve more of your performance issues than removing extraneous if/else clauses ever would.
  9. I haven't gotten into using eval yet. Most of my performance concerns come from both word of mouth and a short game that I made about a year ago. Having about... 15 or so parallel events running and moving about the screen just murdered the frames, though from specific instances I'm wondering if running an animation on the Map wasn't the worst of it.
  10. ZephyrAM said:
    I haven't gotten into using eval yet.
    100% of your code in rmmv software are interpreted by eval()
    Your parallel events are same like Window setTimeout() Method + eval()

    this is unfortunately the only way the software rmmv can communicates with events, scripts.
    it why people have serious sequel of performance.
    The only more complicated but effective solution is to hack all the rmmv engine and make your game in pure script.

    Dont panic because me to with basic (rmmv project) on my i7 ,gtx 1070, i have lag , rmmv are not well optimised.
    but in pure script , i can run over 5000 event without lag .
  11. Jonforum said:
    100% of your code in rmmv software are interpreted by eval()
    What do you mean by this?

    Regarding events, 'eval' is only used in the Script event command, the script option of the Conditional Branch event command, the script option of the Control Variables event command, and the damage formula (there might be 1 or 2 more places that I can't recall).

    For any other event command like showing text, changing self switches, etc. it's just calling JS functions with arguments.