use xmltree::Element;
use std::fs::File;
use std::io::Read;
use std::time::{Instant, Duration};
use std::thread::sleep;
fn main(){
let mut file = File::open("dict.xml").unwrap();
let mut xml_string = String::new();
file.read_to_string(&mut xml_string).unwrap();
let start = Instant::now();
let xml_string = xml_string.replace("", "");
let root = Element::parse(xml_string.as_bytes()).unwrap();
let batch_size = 1;
let children = root.children;
for (_i, chunk) in children.chunks(batch_size).enumerate() {
let mut root = Element::new("LISTOFLEDGERS");
root.children = chunk.to_vec();
sleep(Duration::from_millis(200));
}
let end = Instant::now();
let diff = end.duration_since(start);
println!("The time of execution of above program is {:?}ms", diff.as_millis());
}
Comments
Post a Comment