kastnermario / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Library is too slow #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This Code:
{
    std::ifstream fin("Duck.yaml");
    YAML::Parser parser(fin);

    while(parser)
    {
        YAML::Node doc;
        parser.GetNextDocument(doc);
        std::cout << doc;
    }
}

With the attached file "Duck.yaml" (3d model, converted from COLLADA xml 
to yaml). Size: 326 kb

Loading time: 90 sec
Expected time: 1-3 sec (a speed given COLLADA library)

Compiler: VC9 (MSVS 2008)
Command: /Ox /GL /I "include" /D "WIN32" /D "NDEBUG" /D "_LIB" /D 
"_UNICODE" /D "UNICODE" /FD /EHsc /MD /Gy /Fo"Release\\" /Fd"Release
\vc90.pdb" /W3 /c /Zi /TP

Bad idea to use std::iostream for parsing large files, especially the 
character by character.

Original issue reported on code.google.com by leuki...@gmail.com on 25 Jan 2009 at 2:44

Attachments:

GoogleCodeExporter commented 8 years ago
You're right! (I was surprised myself.) Anyways, now it reads the entire file 
into a
buffer first, and I loaded your file in under a second. Let me know if it works 
for you.

Also, at some point I'll set it up to only read, say, 1MB at a time, so that it
doesn't break if you give it a 4GB file. But for files of reasonable size, it 
should
work fine.

Original comment by jbe...@gmail.com on 1 Feb 2009 at 8:50