Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions src/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ impl Instant {

#[inline]
pub fn elapsed_sec(&self) -> f64 {
duration_to_seconds(self.elapsed())
self.elapsed().as_secs_f64()
}
}

Expand Down Expand Up @@ -881,13 +881,6 @@ pub fn exponential_buckets(start: f64, factor: f64, count: usize) -> Result<Vec<
Ok(buckets)
}

/// `duration_to_seconds` converts Duration to seconds.
#[inline]
pub fn duration_to_seconds(d: Duration) -> f64 {
let nanos = f64::from(d.subsec_nanos()) / 1e9;
d.as_secs() as f64 + nanos
}

#[derive(Clone, Debug)]
pub struct LocalHistogramCore {
histogram: Histogram,
Expand Down Expand Up @@ -1363,16 +1356,6 @@ mod tests {
}
}

#[test]
fn test_duration_to_seconds() {
let tbls = vec![(1000, 1.0), (1100, 1.1), (100_111, 100.111)];
for (millis, seconds) in tbls {
let d = Duration::from_millis(millis);
let v = duration_to_seconds(d);
assert!((v - seconds).abs() < f64::EPSILON);
}
}

#[test]
fn test_histogram_vec_with_label_values() {
let vec = HistogramVec::new(
Expand Down