diff --git a/src/processing/parser/xmltv.rs b/src/processing/parser/xmltv.rs index 63cd4c76e..54dff5891 100644 --- a/src/processing/parser/xmltv.rs +++ b/src/processing/parser/xmltv.rs @@ -142,7 +142,7 @@ impl TVGuide { let match_jw = strsim::jaro_winkler(norm_key, normalized_epg_id); #[allow(clippy::cast_possible_truncation)] #[allow(clippy::cast_sign_loss)] - let mjw = min(100, match_jw as u16 * 100); + let mjw = min(100, (match_jw * 100.0).round() as u16); if mjw >= match_threshold { let mut lock = data.lock().unwrap(); if lock.0 < mjw { diff --git a/src/processing/processor/epg.rs b/src/processing/processor/epg.rs index d8206af81..746ae1769 100644 --- a/src/processing/processor/epg.rs +++ b/src/processing/processor/epg.rs @@ -165,7 +165,7 @@ mod tests { #[test] fn test_phonetic() { - let strings: Vec = (0..5_000_000) + let strings: Vec = (0..5_000) .map(|_| random_string()) .collect(); diff --git a/src/processing/processor/playlist.rs b/src/processing/processor/playlist.rs index 2263295d4..9f60ed563 100644 --- a/src/processing/processor/playlist.rs +++ b/src/processing/processor/playlist.rs @@ -562,7 +562,7 @@ async fn process_playlist_for_target(client: Arc, process_watch(target, cfg, &flat_new_playlist); step.tick("Persisting playlists"); let result = persist_playlist(&mut flat_new_playlist, flatten_tvguide(&new_epg).as_ref(), target, cfg).await; - step.tick(""); + step.stop(); result } } diff --git a/src/utils/step_measure.rs b/src/utils/step_measure.rs index f2aac7295..f5114ba43 100644 --- a/src/utils/step_measure.rs +++ b/src/utils/step_measure.rs @@ -1,5 +1,5 @@ -use std::time::{Duration, Instant}; use log::{debug, log_enabled, Level}; +use std::time::{Duration, Instant}; fn format_duration(duration: Duration) -> String { let millis = duration.as_millis(); @@ -33,10 +33,23 @@ impl StepMeasure { } pub fn tick(&mut self, msg: &str) { - if self.enabled { + if self.enabled { debug!("{} in {}", self.msg, format_duration(self.start.elapsed())); self.msg = msg.to_string(); self.start = Instant::now(); } } + + pub fn stop(&mut self) { + if self.enabled && !self.msg.is_empty() { + debug!("{} in {}", self.msg, format_duration( self.start.elapsed())); + self.enabled = false; + } + } +} + +impl Drop for StepMeasure { + fn drop(&mut self) { + self.stop(); + } } \ No newline at end of file