Hello Robert,

On 10/19/2011 08:22 AM, Robert Petka wrote:
after some further testing, I have found some problem regarding loading
of OSB files. Please see attached code sample (modified
testVRMLLoader.cpp) and correct me if I`m wrong, but it seems that that
loading time of OSB after previously deleting nodes is much higher.
Difference can be seen also on relatively small files. Is there
something wrong in sample code attached?

the code is ok. Since in this case you don't need the changelist to apply changes to a different aspect or send it over the network, you can use commitChangesAndClear() instead of only commitChanges(), but it does not make much of a difference. I've made some tests using a ~370MB .osb [1] and making some small modifications to your test program (see attached).

This is what I get:

round 0 load 0 loadTime 2.37531 total time 2.38646 #live FC 33673 delta live FC 33388 #total FC 36313 delta total FC 36027 round 0 load 1 loadTime 2.75655 total time 2.76888 #live FC 67061 delta live FC 33388 #total FC 72340 delta total FC 36027 round 0 load 2 loadTime 3.01487 total time 3.02778 #live FC 100449 delta live FC 33388 #total FC 108367 delta total FC 36027 round 0 load 3 loadTime 2.95737 total time 2.97041 #live FC 133837 delta live FC 33388 #total FC 144394 delta total FC 36027 round 0 load 4 loadTime 3.55311 total time 3.56635 #live FC 167225 delta live FC 33388 #total FC 180421 delta total FC 36027 round 0 load 5 loadTime 3.06003 total time 3.07341 #live FC 200613 delta live FC 33388 #total FC 216448 delta total FC 36027 round 0 load 6 loadTime 3.05172 total time 3.0652 #live FC 234001 delta live FC 33388 #total FC 252475 delta total FC 36027 round 0 load 7 loadTime 3.06142 total time 3.07493 #live FC 267389 delta live FC 33388 #total FC 288502 delta total FC 36027 round 0 load 8 loadTime 3.07784 total time 3.09135 #live FC 300777 delta live FC 33388 #total FC 324529 delta total FC 36027 round 0 load 9 loadTime 6.07751 total time 6.09102 #live FC 334165 delta live FC 33388 #total FC 360556 delta total FC 36027
round 0 round total time 33.1163
#live FC 285 #total FC 360556

round 1 load 0 loadTime 2.32653 total time 2.33867 #live FC 33673 delta live FC 33388 #total FC 396583 delta total FC 36027 round 1 load 1 loadTime 2.68987 total time 2.70291 #live FC 67061 delta live FC 33388 #total FC 432610 delta total FC 36027 round 1 load 2 loadTime 2.71732 total time 2.73054 #live FC 100449 delta live FC 33388 #total FC 468637 delta total FC 36027 round 1 load 3 loadTime 2.87243 total time 2.88554 #live FC 133837 delta live FC 33388 #total FC 504664 delta total FC 36027 round 1 load 4 loadTime 3.03334 total time 3.04622 #live FC 167225 delta live FC 33388 #total FC 540691 delta total FC 36027 round 1 load 5 loadTime 3.08708 total time 3.09995 #live FC 200613 delta live FC 33388 #total FC 576718 delta total FC 36027 round 1 load 6 loadTime 3.0876 total time 3.10104 #live FC 234001 delta live FC 33388 #total FC 612745 delta total FC 36027 round 1 load 7 loadTime 3.11015 total time 3.1238 #live FC 267389 delta live FC 33388 #total FC 648772 delta total FC 36027 round 1 load 8 loadTime 3.22026 total time 3.23388 #live FC 300777 delta live FC 33388 #total FC 684799 delta total FC 36027 round 1 load 9 loadTime 4.08561 total time 4.09928 #live FC 334165 delta live FC 33388 #total FC 720826 delta total FC 36027
round 1 round total time 30.3623
#live FC 285 #total FC 720826

There is a trend that later loads take a little longer and the 6 secs at the end of round 0 are fairly strange. Overall it does not look like the times are exploding with increasing run time though. The ref counting also seems to work, the 285 live objects are the prototype instances, everything else gets cleaned up. My guess would be that the differences come from variations in heap allocation times and possibly the need to grow certain internal data structures at times. Do you see larger variations on your files or do load times increase more for large files for you?

        Cheers,
                Carsten

[1] I've also used a much smaller file of ~40MB and get similar results.
#include "OSGSceneFileHandler.h"
#include "OSGFieldContainerFactory.h"
#include "OSGTime.h"


int main (int argc, char **argv)
{
    OSG::osgInit(argc,argv);

    OSG::NodeRecPtr              file;
    std::vector<OSG::NodeRecPtr> vFile;

    if(argc <= 1)
    {
        SWARNING << "No model file given on command line. Exiting."
                 << std::endl;
        OSG::osgExit();

        return 1;
    }

    std::cout << "#live FC " << OSG::FieldContainerFactory::the()->getNumLiveContainers()
              << " #total FC " << OSG::FieldContainerFactory::the()->getNumTotalContainers()
              << std::endl;

    const OSG::UInt32 numRounds =  2;
    const OSG::UInt32 numLoads  = 10;

    vFile.reserve(numLoads);

    for(OSG::UInt32 r = 0; r < numRounds; ++r)
    {
        OSG::Time startRound = OSG::getSystemTime();

        for(OSG::UInt32 i = 0; i < numLoads; ++i)
        {
            OSG::UInt32 startLiveFC  = OSG::FieldContainerFactory::the()->getNumLiveContainers();
            OSG::UInt32 startTotalFC = OSG::FieldContainerFactory::the()->getNumTotalContainers();

            OSG::Time start = OSG::getSystemTime();
            file = OSG::SceneFileHandler::the()->read(argv[1], NULL);
            
            OSG::Time loadTime = OSG::getSystemTime() - start;

            vFile.push_back(file);
            OSG::commitChangesAndClear();
            file = NULL;

            OSG::Time totalTime  = OSG::getSystemTime() - start;

            OSG::UInt32 endLiveFC  = OSG::FieldContainerFactory::the()->getNumLiveContainers();
            OSG::UInt32 endTotalFC = OSG::FieldContainerFactory::the()->getNumTotalContainers();

            std::cout << "round " << r
                      << " load " << i
                      << " loadTime "   << loadTime
                      << " total time " << totalTime
                      << " #live FC "  << endLiveFC  << " delta live FC "  << (endLiveFC - startLiveFC)
                      << " #total FC " << endTotalFC << " delta total FC " << (endTotalFC - startTotalFC)
                      << std::endl;

        }

        OSG::Time roundTotal = OSG::getSystemTime() - startRound;

        std::cout << "round " << r
                  << " round total time " << roundTotal << std::endl;

        OSG::commitChangesAndClear();

        vFile.clear();

        OSG::commitChangesAndClear();

        std::cout << "#live FC " << OSG::FieldContainerFactory::the()->getNumLiveContainers()
                  << " #total FC " << OSG::FieldContainerFactory::the()->getNumTotalContainers()
                  << std::endl;
    }

    OSG::osgExit();

    return 0;
}
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Ciosco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to