Removed the file open syscall from the benchmark.
This commit is contained in:
parent
58e11f17b7
commit
6996759db5
@ -46,41 +46,37 @@ fn bench_index_test_files(b: &mut Bencher) {
|
|||||||
// complete_index runs in parallel so it requires a mutex as argument.
|
// complete_index runs in parallel so it requires a mutex as argument.
|
||||||
let m = Arc::new(Mutex::new(db));
|
let m = Arc::new(Mutex::new(db));
|
||||||
|
|
||||||
// vec of (path, url) tuples.
|
// include them in the binary to avoid loading from disk making file open syscalls.
|
||||||
|
let pcper = include_bytes!("feeds/pcpermp3.xml");
|
||||||
|
let unplugged = include_bytes!("feeds/linuxunplugged.xml");
|
||||||
|
let radio = include_bytes!("feeds/coderradiomp3.xml");
|
||||||
|
let snap = include_bytes!("feeds/techsnapmp3.xml");
|
||||||
|
let las = include_bytes!("feeds/TheLinuxActionShow.xml");
|
||||||
|
|
||||||
|
// vec of (&vec<u8>, url) tuples.
|
||||||
let urls = vec![
|
let urls = vec![
|
||||||
|
(pcper.as_ref(), "https://www.pcper.com/rss/podcasts-mp3.rss"),
|
||||||
(
|
(
|
||||||
"benches/feeds/pcpermp3.xml",
|
unplugged.as_ref(),
|
||||||
"https://www.pcper.com/rss/podcasts-mp3.rss",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"benches/feeds/linuxunplugged.xml",
|
|
||||||
"http://feeds.feedburner.com/linuxunplugged",
|
"http://feeds.feedburner.com/linuxunplugged",
|
||||||
),
|
),
|
||||||
|
(radio.as_ref(), "https://feeds.feedburner.com/coderradiomp3"),
|
||||||
|
(snap.as_ref(), "https://feeds.feedburner.com/techsnapmp3"),
|
||||||
(
|
(
|
||||||
"benches/feeds/coderradiomp3.xml",
|
las.as_ref(),
|
||||||
"https://feeds.feedburner.com/coderradiomp3",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"benches/feeds/techsnapmp3.xml",
|
|
||||||
"https://feeds.feedburner.com/techsnapmp3",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"benches/feeds/TheLinuxActionShow.xml",
|
|
||||||
"https://feeds2.feedburner.com/TheLinuxActionShow",
|
"https://feeds2.feedburner.com/TheLinuxActionShow",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
urls.par_iter().for_each(|&(path, url)| {
|
urls.par_iter().for_each(|&(buff, url)| {
|
||||||
let tempdb = m.lock().unwrap();
|
|
||||||
// Create and insert a Source into db
|
// Create and insert a Source into db
|
||||||
let s = insert_return_source(&tempdb, url).unwrap();
|
let s = {
|
||||||
drop(tempdb);
|
let temp = m.lock().unwrap();
|
||||||
|
insert_return_source(&temp, url).unwrap()
|
||||||
// open the xml file
|
};
|
||||||
let feed = fs::File::open(path).unwrap();
|
|
||||||
// parse it into a channel
|
// parse it into a channel
|
||||||
let chan = rss::Channel::read_from(BufReader::new(feed)).unwrap();
|
let chan = rss::Channel::read_from(buff).unwrap();
|
||||||
|
|
||||||
// Index the channel
|
// Index the channel
|
||||||
complete_index(&m, &chan, &s).unwrap();
|
complete_index(&m, &chan, &s).unwrap();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user