jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
5.14k stars 1.85k forks source link

performance #158

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Maybe some wrongs with my codes, the codes is following:
the code of parsing this attached file in C++:
    std::ifstream file("test.yaml");
    YAML::Parser parser(file);
    YAML::Node document;
    parser.GetNextDocument(document);

the code of parsing this attached file in C:
    file = fopen("test.yaml", "rb");
    yaml_parser_initialize(&parser);
    yaml_parser_set_input_file(&parser, file);
    while (!done)
    {
        if (!yaml_parser_load(&parser, &document)) {
            error = 1;
            break;
        }
        done = (!yaml_document_get_root_node(&document));
        yaml_document_delete(&document);

        if (!done) count ++;
    }
    fclose(file);

Original issue reported on code.google.com by cmt75...@gmail.com on 9 Apr 2012 at 3:20

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks!

You're definitely doing it right, and this is too slow. I'll see what I can do.

Original comment by jbe...@gmail.com on 9 Apr 2012 at 3:54

GoogleCodeExporter commented 9 years ago

Original comment by jbe...@gmail.com on 18 May 2012 at 6:32

GoogleCodeExporter commented 9 years ago

Original comment by jbe...@gmail.com on 19 May 2012 at 9:09

GoogleCodeExporter commented 9 years ago
Any progress on this issue? I like yaml-cpp but the performance is very bad

Original comment by dael...@gmail.com on 11 Oct 2012 at 8:32

GoogleCodeExporter commented 9 years ago
Sorry, I've been very busy. I have a plan, but I just haven't had time to 
execute it.

Original comment by jbe...@gmail.com on 11 Oct 2012 at 1:06

GoogleCodeExporter commented 9 years ago
Is it a big issue? If you point me in the direction I can play around with it.

Original comment by dael...@gmail.com on 11 Oct 2012 at 1:33

GoogleCodeExporter commented 9 years ago
Sorta, yeah, I'm planning a major refactor. The steps are:

1. Refactor the file IO to make it easier to ensure that a certain amount is 
buffered for random access.

2. Refactor the scanning (this is where most of the inefficiency lies)

3. Refactor tokens to not copy strings, when they can (this is the rest of the 
inefficiency)

Original comment by jbe...@gmail.com on 11 Oct 2012 at 1:38

GoogleCodeExporter commented 9 years ago
Any updates on this? 

I've been using yaml-cpp in one of my projects and quite like its API, but I 
have a 5 MB yaml file that takes 50s to load. 5 MB is big for a yaml file, I 
suppose, but 50s seems to be far too long IMHO. I'm considering switching over 
to libyaml to see how fast that can do it, but I don't really want to have to 
work with a C API.

Original comment by WrinklyN...@gmail.com on 2 Aug 2013 at 12:53

GoogleCodeExporter commented 9 years ago
Sorry, I just don't expect to get to this for a while - life precludes going on 
one of the coding stretches that I did in my younger days :)

Original comment by jbe...@gmail.com on 2 Aug 2013 at 1:09

GoogleCodeExporter commented 9 years ago
Well, I'm not a brilliant coder, but I'd be happy to try making some 
improvements if you were to point me in the right direction. 

Original comment by WrinklyN...@gmail.com on 2 Aug 2013 at 1:31

GoogleCodeExporter commented 9 years ago
I listed the basic steps above - but as a caution, if you plan to actually work 
on this (which would be awesome!), the resulting patch would be farily large, 
so make sure you break up your patch into many (many!) small pieces to make it 
easier to code-review.

Original comment by jbe...@gmail.com on 2 Aug 2013 at 1:44