computation time test
This commit is contained in:
parent
df727889c6
commit
f97858cd63
3 changed files with 25 additions and 3 deletions
BIN
main
BIN
main
Binary file not shown.
3
main.rs
3
main.rs
|
@ -1,3 +0,0 @@
|
||||||
pub fn main() {
|
|
||||||
println!("{}", u128::MAX / 1000);
|
|
||||||
}
|
|
25
src/lib.rs
25
src/lib.rs
|
@ -213,6 +213,31 @@ mod test {
|
||||||
assert!(!config.is_valid_proof(&pw2, &phrase));
|
assert!(!config.is_valid_proof(&pw2, &phrase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_time(prev: u128, current: u128) -> bool {
|
||||||
|
if prev < current {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn computation_time_test() {
|
||||||
|
use std::time::Instant;
|
||||||
|
const DIFFICULTY: u32 = 50000;
|
||||||
|
|
||||||
|
let target = "testing";
|
||||||
|
let config = get_config();
|
||||||
|
let mut current = Instant::now();
|
||||||
|
config.prove_work(&target, DIFFICULTY).unwrap();
|
||||||
|
let prev = current.elapsed().as_nanos();
|
||||||
|
|
||||||
|
current = Instant::now();
|
||||||
|
config.prove_work(&target, DIFFICULTY * 10).unwrap();
|
||||||
|
let tmp = current.elapsed().as_nanos();
|
||||||
|
assert!(check_time(prev, tmp));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialization_test() {
|
fn serialization_test() {
|
||||||
let target: u8 = 1;
|
let target: u8 = 1;
|
||||||
|
|
Loading…
Reference in a new issue