sapling/eden/scm/lib/configparser/benches/bench.rs
Adam Simpkins ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00

38 lines
1.0 KiB
Rust

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::io::Write;
use bytes::Bytes;
use minibench::{bench, elapsed};
use configparser::config::ConfigSet;
fn main() {
bench("parse 645KB file", || {
let mut config_file = Vec::new();
for _ in 0..100 {
for section in b'a'..b'z' {
config_file
.write(format!("[{ch}{ch}{ch}{ch}]\n", ch = section as char).as_bytes())
.unwrap();
for name in b'a'..b'z' {
config_file
.write(
format!("{ch}{ch}{ch} = {ch}{ch}{ch}\n", ch = name as char).as_bytes(),
)
.unwrap();
}
}
}
elapsed(|| {
let mut cfg = ConfigSet::new();
cfg.parse(Bytes::from(&config_file[..]), &"bench".into());
})
});
}