diff --git a/tikv-client-common/src/stats.rs b/tikv-client-common/src/stats.rs index 8ecdcd1..2bd647a 100644 --- a/tikv-client-common/src/stats.rs +++ b/tikv-client-common/src/stats.rs @@ -1,8 +1,8 @@ // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. -use crate::{util::duration_to_sec, Result}; +use crate::Result; use prometheus::{Histogram, HistogramVec, IntCounterVec}; -use std::time::Instant; +use std::time::{Duration, Instant}; pub struct RequestStats { start: Instant, @@ -125,3 +125,11 @@ lazy_static! { ) .unwrap(); } + +/// Convert Duration to seconds. +#[inline] +fn duration_to_sec(d: Duration) -> f64 { + let nanos = f64::from(d.subsec_nanos()); + // In most cases, we can't have so large Duration, so here just panic if overflow now. + d.as_secs() as f64 + (nanos / 1_000_000_000.0) +} diff --git a/tikv-client-common/src/util.rs b/tikv-client-common/src/util.rs index 869a864..989074a 100644 --- a/tikv-client-common/src/util.rs +++ b/tikv-client-common/src/util.rs @@ -1,7 +1,5 @@ // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. -use std::time::Duration; - #[macro_export] macro_rules! internal_err { ($e:expr) => ({ @@ -14,11 +12,3 @@ macro_rules! internal_err { internal_err!(format!($f, $($arg),+)) }); } - -/// Convert Duration to seconds. -#[inline] -pub fn duration_to_sec(d: Duration) -> f64 { - let nanos = f64::from(d.subsec_nanos()); - // In most cases, we can't have so large Duration, so here just panic if overflow now. - d.as_secs() as f64 + (nanos / 1_000_000_000.0) -}