Code Monkey home page Code Monkey logo

Comments (10)

xitep avatar xitep commented on May 31, 2024

Can you post your code? How are you reading the file? Note, the example from the project main page doesn't use a BufReader so this might actually be the bottleneck.

from xml-rs.

s-trooper avatar s-trooper commented on May 31, 2024

just like example

let file = File::open(&filename).unwrap();
let start = PreciseTime::now();
let mut parser = EventReader::new(file);

for e in parser.events() {
    match e {
        XmlEvent::StartElement { name, .. } => {
        }
        XmlEvent::EndElement { name } => {
        }
        XmlEvent::Error(e) => {
            println!("Error: {}", e);
            break;
        }
        _ => {}
    }
}
let end = PreciseTime::now();
println!("{} seconds for whatever you did.", start.to(end));

from xml-rs.

xitep avatar xitep commented on May 31, 2024

Can you try wrapping file with BufReader? https://doc.rust-lang.org/stable/std/io/struct.BufReader.html

Something along the lines of:

let file = File::open(...)...
let file = BufReader::new(file)...
...

I'd be interested how much this helps.

from xml-rs.

netvl avatar netvl commented on May 31, 2024

Yes, the example on the main page was written when File was a buffered reader itself, it was long time ago. I didn't update it for BufReader since. Because xml-rs essentially processes the input code point-wise, it is very likely that absence of buffering is the bottleneck.

If BufReader won't help, could you please post the XML document you're working with? I'll try to look what's happening there.

from xml-rs.

s-trooper avatar s-trooper commented on May 31, 2024

with BufReader:
rust: 00.525 sec

for me its ok the issue can be closed but as incentive:
nim: 0.049 sec (xmlparser) :-)

from xml-rs.

xitep avatar xitep commented on May 31, 2024

Would you mind trying and posting the result with rust-{beta,nightly}? :)

from xml-rs.

netvl avatar netvl commented on May 31, 2024

Yeah, I didn't optimize the parser very much, it is very likely that there are bottlenecks. I have some work on this in dev branch.

from xml-rs.

s-trooper avatar s-trooper commented on May 31, 2024

just for fun nightly: 0.475 sec. but honestly the rust compiler will not generate 10x faster binaries in near future ;-)

from xml-rs.

xitep avatar xitep commented on May 31, 2024

sure, i fully agree. i just was curious how much things have changed on nightly since the 1.1 release. many thanks so far.

from xml-rs.

netvl avatar netvl commented on May 31, 2024

I guess I'm closing this for now. Feel free to reopen if you still have problems.

from xml-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.