Which one is quicker?



  • Hi all,

    JUST THEORY.

    I have a struct called "mainStruct" with three records. -> mainStruct { QString pname, pcmd, pid};
    The struct has 'n' rows. I don't known how much. ( 10 > ~ < 100)
    I would like to refresh the "list".
    How to?

    At each step I overwriting the struct or, I search what cells are changed/removed/added and changed just these cells? This is a long time because I will have much if.

    What is the best choice?



  • If I were you (since it seems to me as if you have a unique pid for each struct):

    1. I'd change the struct to a small class that emits a "hasChanged( pid )" signal any time any of its internal variables change.
    2. Stick the structs (now small classes) into a map (pid as key).
    3. Connect the hasChanged() signal to a slot that updates the map based on the received pid (key).

    I hope that makes sense...I'm a bit pressed for time right now so will leave it at that.



  • If you have time to experiment then try and implement different approaches to your problem. You can use QTestLib to take some "measurements":http://qt-project.org/doc/qt-4.8/qtestlib-manual.html#creating-a-benchmark and compare numbers.
    IMHO, if data structure is really so simple, if row count will be held between 10 and 100 and you are not going to run your program on some embedded device or anything really slow then you most likely won't see much difference in speed if any.



  • [quote author="goblincoding" date="1342608039"]If I were you (since it seems to me as if you have a unique pid for each struct):

    1. I'd change the struct to a small class that emits a "hasChanged( pid )" signal any time any of its internal variables change.
    2. Stick the structs (now small classes) into a map (pid as key).
    3. Connect the hasChanged() signal to a slot that updates the map based on the received pid (key).

    I hope that makes sense...I'm a bit pressed for time right now so will leave it at that.[/quote]

    Thanks goblin. I will try your idea.



  • [quote author="sidewinder" date="1342615854"]If you have time to experiment then try and implement different approaches to your problem. You can use QTestLib to take some "measurements":http://qt-project.org/doc/qt-4.8/qtestlib-manual.html#creating-a-benchmark and compare numbers.
    IMHO, if data structure is really so simple, if row count will be held between 10 and 100 and you are not going to run your program on some embedded device or anything really slow then you most likely won't see much difference in speed if any.[/quote]

    Yes, I have time. ( I'm on summer holiday). So I will try also your idea.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.