mirror of https://github.com/tikv/client-rust.git
Move duration util fn to stats
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
parent
1f5387ddfe
commit
e7bd456722
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue