Comments (10)
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.
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.
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.
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.
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.
Would you mind trying and posting the result with rust-{beta,nightly}? :)
from xml-rs.
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.
just for fun nightly: 0.475 sec. but honestly the rust compiler will not generate 10x faster binaries in near future ;-)
from xml-rs.
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.
I guess I'm closing this for now. Feel free to reopen if you still have problems.
from xml-rs.
Related Issues (20)
- Overflow in lexer when parsing malformed doctype HOT 1
- Fails to parse /> as part of XML body HOT 7
- Implement the position trait for the Events Iterator
- panicked at 'attempt to add with overflow' HOT 2
- Feature request: common Error enum for read/write
- Restricted XmlEvent? HOT 1
- [Question] How to implement streaming parsing? HOT 1
- deprecation warnings HOT 1
- Is this crate abandoned? HOT 3
- Parsing of comments <!-- <!-->
- Maintenance of xml-rs HOT 10
- EventReader never return Result::Err after document end HOT 1
- Version 0.8.9 broke deserialization behavior HOT 2
- 0.8.12's field types in xml::common::TextPosition break existing code HOT 1
- Panic in `PullParser::push_pos()` HOT 1
- You've found a bug in xml-rs, caused by calls to push_pos() HOT 3
- Profile-Guided Optimization (PGO) results HOT 2
- Simple way to remove whitespaces HOT 1
- Deal with files that start with empty line HOT 2
- Add default "xmlns" on ParserConfig2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xml-rs.