What's the smartest way to deal with variables?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I didn't know that, Danny! Thanks for the suggestion! I'll take a look at the object right now. So far, it looks really nice. I won't even need the source code to do the port to Android but I'll get ahold of him if I run into anything. :)

  • Also note the overhead in windows control objects like Edit Box, List, Input Box, etc might not be present in non-windows runtimes as they would each handles lists slightly differently... so a conversion of LB's extension to mobile might not yield a huge improvement in performance.

    But I can't stress how important it is to be careful with List/Edit Box object for Windows runtimes, in an Please login to see this link., the time different for loading it into a edit box and a string was:

    Edit Box - 30 seconds
    String - 0.5 seconds

    Please login to see this link.

  • That's excellent tompa - thanks!

    Woah, after reading through the thread, I was considering using the Named Variable for everything. But 2340% slower writing speed? Ouch.

    Weird how it's faster with writing string (but way slower when reading string), while most of the others are slower with writing string.

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

  • tompa, out of curiosity, could you redo it with the build 284 when you get a chance to install it?

    Mathias, we know that your framework is faster as it's compiled, so what's the point of doing comparisons again and again? EDIT: removed my other comment, ask me if you want it :p

  • Thanks! Here is my results with the build 284, same processor as yours. The results with the build 284 as faster as expected but I wonder why I get so different results for retrieving texts from Windows controls... What version of Windows to you use? (Windows 8.1 here)

    Please login to see this picture.

  • I am currently using either name variables or strings, didn't know it was such a problem during writing. But this should only be a problem if your only doing huge applications with lots of data am I correct. Simple apps and games shouldn't be too hard, no?

    The soul of the sluggard craves and gets nothing, while the soul of the diligent is richly supplied -Pro 13:4

  • Quote

    I am currently using either name variables or strings, didn't know it was such a problem during writing. But this should only be a problem if your only doing huge applications with lots of data am I correct. Simple apps and games shouldn't be too hard, no?

    You have to look at this as a percentage instead of as an absolute value. If you're writing a string 1,000,000 times with one loop, then yes, you absolutely need to take this into account because one object may be hundreds of times faster than the another object is (a percentage).

    Now, if you're writing 10 times instead of 1,000,000 times, the percent is still the same (one object may be hundreds of times faster than another one is), but the actual time taken is minuscule and basically not worth the consideration. This is why I recommend the list object (and now the internal list object! Thanks, Danny!) for most tasks where usability/flexibility trumps efficiency.

  • This has been a great read so far. And while it makes me paranoid that they way I have been doing things currently in my project are very inefficient, it is good to know. I use list objects all the time for holding tile patterns and strings for shops and dialogue. I always keep them invisible so switching to the internal list would be great...except I need a solution for all mobile runtimes. That is the major concern I have in general with using non-standard extensions: they aren't always ported to all runtimes. And at this stage, I tend to make all my games for at least mobile and windows.

    Snail, if you do convert it to ios and android, I would be more than happy to help test it.

    Please login to see this link.

  • Thanks for the offer! I'm working on it right now. :) I don't have the iOS exporter so I don't know anything about porting it to that, but Android's fairly straightforward.

  • I just saw your video on sorting a List with one event line. Great stuff. I get very confused by the MMF syntax in expressions like that, but I think I need to get more intimate with the List object. In the future, can you make sure to use the Event List Editor? It makes reading the code in a video easier, since you aren't rolling over all the event check boxes. ;)

    Please login to see this link.

  • I'm about to run a test on Android to see the performance difference. One second.

    On an Android phone with 50,000 Read Line expressions and 50,000 Change Line actions:

    List
    read: 1141ms
    write: 659ms

    Internal List
    read: 466ms
    write: 358ms

    Active:
    read: 285
    write: 256

    There are a few more changes I want to make but I'll finish it this weekend. There's one place that I can think of where the writing might be slowing down. Reading I can't control unless there's a faster way to access the list on Android that I don't know about. Copy() is going to take me some time to implement efficiently. A few actions that you will want to avoid if speed is paramount:

    Copy Items()
    Sort List in Rage()
    Load List from File()
    Load List from String()

    and the expressions:

    Get Number of Item Occurrences()
    Get Index of Item by Occurrence()
    Custom Sort: Get String A()
    Custom Sort: Get String B()

    Not sure what Reserve More Space does on Windows. Okay, I see it in an example. I'll see if Android reserves memory the same way.

    Thanks for the suggestion, Mobichan!

    Edited 5 times, last by Snail (March 5, 2015 at 12:49 AM).

  • My results in Windows 7 (shown on right) are pretty similar to Tompa's, though my numbers tend to pe slightly slower all-round. Tompa's CPU is slightly better than mine, though therePlease login to see this link.. And mine is overclocked an extra 0.4Ghz, which should help offset any difference. So that would suggest that the most of the extra speed comes from Windows 8.1, which is interesting.

    EDIT: Actually, looking at it again, it's about even: some things are higher in Win7 and some things are lower.

    Please login to see this picture.

    I also noticed that there's no real multithreading going on. Below is a picture of my system stats taken while running Tompa's speedtest. Everything happens on one core, leaving the other 7 with nothing to do. Might multithreading be a source of untapped potential for future versions of Fusion?

    Please login to see this picture.

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

    Edited once, last by Volnaiskra (March 5, 2015 at 5:22 AM).

  • Quote from Volnaiskra

    Might multithreading be a source of untapped potential for future versions of Fusion?

    It would be very hard for Fusion to reason about parallelism, at least for events.
    Users expect events to happen sequentially, and you would need some very complicated dependency analysis to figure out how to split the events into separate jobs.
    Systems like physics and rendering are much easier to parallelize, but in the case of Fusion, those account for very little of the total runtime.
    Events account for 90% of the total runtime on desktop, so those are the real bottleneck.

    The following can be done to optimize those more:
    1) Merge similar event groups, where the user was trying to describe a branch, e.g.

    Code
    If alterable string of Object A == "active"
    If alterable value of Object A == 1
        Set position X of Object A to 5
    
    
    If alterable string of Object A == "active"
    If alterable value of Object A == 0
        Set position X of Object A to 4

    What the user was really trying to describe was this:

    Code
    If alterable string of Object A == "active"
        If alterable value of Object A == 1
            Set position X of Object A to 5
        If alterable value of Object A == 0
            Set position X of Object A to 4

    Fusion does not have this optimization. I would be surprised if F3 won't have some way to describe this explicitly :)
    2) Move to native code
    3) Optimize for the statistically likely cases/branches. Yves worked a lot on this for build 284 for globals, alterables and flags.
    4) Optimize cache usage. Objects use a lot of pointers internally in Fusion, so for e.g. every alterable read, 1 level of indirection needs to be followed. This could be optimized to 0.

    Sorry for the performance rant, but I hope that gave some insight into the "real" opportunities for runtime developers.

    Edited once, last by Simon: CP (February 19, 2018 at 9:24 PM).

  • 1) I usually do with groups

    However I can't figure out if the overhead of the group is cancelling out the gains from removing the duplicate checking... and of course nested conditions would solve this problem entirely rather than doing it at the back end.

    Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!