Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab4ae36
commit 493d595
Showing
8 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use super::FirstSecond::*; | ||
use super::FirstSecond::{First, Second}; | ||
use super::*; | ||
|
||
mod with_atom_first; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use super::FirstSecond::*; | ||
use super::FirstSecond::{First, Second}; | ||
use super::*; | ||
|
||
mod with_atom_first; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use super::*; | ||
|
||
use std::thread; | ||
use std::time::Duration; | ||
|
||
#[test] | ||
fn increases_after_2_native_time_units() { | ||
with_process(|process| { | ||
let first = erlang::monotonic_time_0(process); | ||
|
||
thread::sleep(Duration::from_millis(2)); | ||
|
||
let second = erlang::monotonic_time_0(process); | ||
|
||
assert_eq!(erlang::is_less_than_2(first, second), true.into()) | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::time::Instant; | ||
|
||
use num_bigint::BigInt; | ||
|
||
use crate::time::convert; | ||
use crate::time::Unit::{self, *}; | ||
|
||
pub fn time(unit: Unit) -> BigInt { | ||
let duration = START.elapsed(); | ||
|
||
match unit { | ||
Second => duration.as_secs().into(), | ||
Millisecond => duration.as_millis().into(), | ||
Microsecond => duration.as_micros().into(), | ||
Nanosecond => duration.as_nanos().into(), | ||
_ => convert(duration.as_nanos().into(), Nanosecond, unit), | ||
} | ||
} | ||
|
||
lazy_static! { | ||
static ref START: Instant = Instant::now(); | ||
} |