User Tag List

Results 1 to 10 of 10

Thread: Is comparing values faster than comparing strings?

  1. #1
    Clicker Fusion 2.5

    Join Date
    Feb 2014
    Location
    Sweden
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Is comparing values faster than comparing strings?

    The game I'm working on loads each level from information in an INI file. When loading each background object, the item "Obstacle" determines whether or not the object should be set to Obstacle.
    At the moment, I use a string for this:

    Obstacle=Yes

    However, for some reason I imagine comparing values may be faster than comparing strings. Since some levels may load over 5000 objects this way, and I of course want the levels to load as fast as possible, I'm thinking of using a value comparison instead:

    Obstacle=1

    How much of a difference would it make?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module

    Join Date
    Dec 2013
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I know the information in the ini is already handled as strings and reading a number would probably cost more time during integer conversion. I still doubt you will see any change at all. However switching from Ini to Array you will see a huge performance jump.

  3. #3
    Clicker Fusion 2.5

    Join Date
    Feb 2014
    Location
    Sweden
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using the INI++ object, don't know if that makes any difference... so are you saying that arrays are always faster than INI:s, or is it just if I would switch to a Value array?

    I figured that when loading the levels, or performing searches, INI:s would be more effective since a FastLoop could iterate through each existing group, rather than having to iterate through all the cells that would be left empty in an array.

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,691
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    A list, with speed comparison, for accessing data (time taken for 40k operations in hundredths of seconds).
    Alterable String of the Active - 15
    String Object - 16
    Data Store - 19
    MagicDeque - 22
    Global String - 28
    Dynamic Array - 31
    GlobalStoreX - 33
    Binary Array - 35
    Array - 39
    Associative Array - 44
    Named Variable - 50
    String Parser 2 - 59
    Static String - 356
    List – 506
    Combo Box - 1197
    INI - 3892

    Marv
    ​455 MMF2 & CTF 2.5 Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module

    Join Date
    Dec 2013
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly Marv. I ditched all INI solutions in my projects and for example, on a large strategy board game the loading time went from around 6 seconds to zero.

    Yes I know INI is super easy to read, write, work with it and the implementation is cheap while array is cumbersome, difficulty to understand and implementing and changing stuff is a pain - plus after a week of coding time you know longer know what information is stored in which cell, but on the speed side there is literary nothing that will be much faster.

  6. #6
    Clicker Fusion 2.5

    Join Date
    Feb 2014
    Location
    Sweden
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help everybody. Wow, I had never thought the difference could be that big. Right now I really wish I would have taken the time to ask this before I spent a whole year working on a game that completely relies on INI:s for data storage Since my main concern is the loading times, it seems to make the most sense to re-code the loading and saving of level data using array objects instead. I think I'll stick with the INI:s for inventory, dialogue and such, where data access time is less of a concern and easy editing a bigger priority.

    Which brings me to another question - does the size of the INI file affect the time required for reading/writing its data? From what I've noticed, performing an INI++ search takes longer if the file is big, which makes sense since it has to iterate through a larger number of groups and items. But is there any difference when reading/writing a specified item?

  7. #7
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very interesting Marv.

    Static String - 356 is surprising to me, seems like static strings should be avoided for storing values
    MagicDeque - 22 is fantastic, this has been my go-to extension for dynamic arrays for a while now
    List – 506 this is better than I expected. IMO List should be avoided all together for its horrendous time required to add lines or load from files.

    INI - 3892 - I don't think this is the same as INI++, I've used INI++ for my projects and the response is quite fast, once loaded of course.

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,691
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Hi Ryan. It would be great to run the test for INI++ to see the difference. I kind of thought so my self. I think the testing was done before INI++ existed.

    Marv
    ​455 MMF2 & CTF 2.5 Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  9. #9
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I agree, also the tester would have to rerun the tests on all extensions to ensure the hardware doesn't factor into the new results.

    The issue with INI++ is lack of unicode compatibility, so my next hope is to trial building an application using Binary Array for data storage, which I'm led to believe to has unicode support.

  10. #10
    Clicker Fusion 2.5

    Join Date
    Feb 2014
    Location
    Sweden
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Snail View Post
    Reading from and writing to an .ini file will take longer if the file's bigger than it will if it's smaller. Remember, .ini files are nothing more than plain-text files. The INI object (and I assume the INI++) operates the same way a text editor operates. In most situations, the speed difference is irrelevant, so you'd want to whichever object is the easiest for you and does everything you want it to do. When speed becomes more important, you need to take things like read/write times into consideration and then find a balance between usability and performance.
    What about reading from/writing to an array then, or an Associative Array? Would the amount of data stored in it affect the data access times as well, just like with the INI object?

Similar Threads

  1. Comparing position, adding values
    By J3sseM in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 15th March 2013, 05:44 PM
  2. comparing values on overlap
    By itsa_doozy in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 6th March 2013, 06:19 PM
  3. PROBLEM COMPARING FLOATING VALUES
    By Fernando in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 18th August 2011, 08:12 PM
  4. [BUG] PROBLEM COMPARING FLOATING VALUES
    By Fernando in forum Android Export Module Version 2.0
    Replies: 0
    Last Post: 6th August 2011, 05:40 PM
  5. Comparing 2 global values question
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 19th January 2009, 04:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •