Added benchmark for testing

This commit is contained in:
G2-Games 2023-11-03 09:49:53 -05:00
parent eeceb27800
commit 421ab0c757
2 changed files with 5 additions and 4 deletions

View file

@ -85,6 +85,6 @@ impl MusicController {
sort_by: Vec<Tag>, sort_by: Vec<Tag>,
) -> Option<Vec<&Song>> { ) -> Option<Vec<&Song>> {
self.library self.library
.query(query_string, &target_tags, &sort_by) .query_tracks(query_string, &target_tags, &sort_by)
} }
} }

View file

@ -664,7 +664,7 @@ impl MusicLibrary {
/// ///
/// Example: /// Example:
/// ``` /// ```
/// query( /// query_tracks(
/// &String::from("query"), /// &String::from("query"),
/// &vec![ /// &vec![
/// Tag::Title /// Tag::Title
@ -680,7 +680,7 @@ impl MusicLibrary {
/// This would find all titles containing the sequence /// This would find all titles containing the sequence
/// "query", and would return the results sorted first /// "query", and would return the results sorted first
/// by path, then album, disk number, and finally track number. /// by path, then album, disk number, and finally track number.
pub fn query( pub fn query_tracks(
&self, &self,
query_string: &String, // The query itself query_string: &String, // The query itself
target_tags: &Vec<Tag>, // The tags to search target_tags: &Vec<Tag>, // The tags to search
@ -773,7 +773,7 @@ impl MusicLibrary {
None => continue None => continue
}; };
match albums.binary_search_by_key(&normalize(&title), |album| normalize(&album.title.to_owned())) { match albums.binary_search_by_key(&title, |album| album.title) {
Ok(pos) => { Ok(pos) => {
albums[pos].tracks.push(result); albums[pos].tracks.push(result);
}, },
@ -791,4 +791,5 @@ impl MusicLibrary {
Ok(albums) Ok(albums)
} }
} }