optimize millis_since_unix_epoch()
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
08274150e5
commit
db46d6dd6b
2 changed files with 7 additions and 7 deletions
|
@ -23,7 +23,7 @@ pub use mutex_map::MutexMap;
|
|||
pub use rand::string as random_string;
|
||||
pub use string::{str_from_bytes, string_from_bytes};
|
||||
pub use sys::available_parallelism;
|
||||
pub use time::millis_since_unix_epoch;
|
||||
pub use time::now_millis as millis_since_unix_epoch;
|
||||
|
||||
use crate::Result;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[allow(clippy::as_conversions)]
|
||||
pub fn millis_since_unix_epoch() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("time is valid")
|
||||
pub fn now_millis() -> u64 {
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
UNIX_EPOCH
|
||||
.elapsed()
|
||||
.expect("positive duration after epoch")
|
||||
.as_millis() as u64
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue