mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
config: fix configloader benchmark
Summary: Fix compile of the benchmark logic. Reviewed By: muirdm Differential Revision: D42035999 fbshipit-source-id: 00d59f033bd3caf128d72b127908e952e6fb1aac
This commit is contained in:
parent
6d961bd3f8
commit
7637c9cae0
@ -5,33 +5,26 @@
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use bytes::Bytes;
|
||||
use configloader::config::ConfigSet;
|
||||
use configloader::Text;
|
||||
use minibench::bench;
|
||||
use minibench::elapsed;
|
||||
|
||||
fn main() {
|
||||
bench("parse 645KB file", || {
|
||||
let mut config_file = Vec::new();
|
||||
let mut config_file = String::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();
|
||||
config_file += &format!("[{ch}{ch}{ch}{ch}]\n", ch = section as char);
|
||||
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();
|
||||
config_file += &format!("{ch}{ch}{ch} = {ch}{ch}{ch}\n", ch = name as char);
|
||||
}
|
||||
}
|
||||
}
|
||||
let text = Text::from(config_file);
|
||||
elapsed(|| {
|
||||
let mut cfg = ConfigSet::new();
|
||||
cfg.parse(Bytes::from(&config_file[..]), &"bench".into());
|
||||
cfg.parse(text.clone(), &"bench".into());
|
||||
})
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user