Compare commits

...

2 Commits

Author SHA1 Message Date
b1ek a3b47f3e47
add benchmarks to example 2023-08-02 20:21:49 +10:00
b1ek 14915d8f31
add trait to convert Num to u128 2023-08-02 20:21:38 +10:00
2 changed files with 20 additions and 3 deletions

View File

@ -1,7 +1,18 @@
use powlib::{self, gen::{POWRange, POWChallenge}};
use std::time::Instant;
use powlib::{self, gen::{POWRange, POWChallenge}, hash::hash_num, num::Num};
fn main() {
let challenge = POWChallenge::make(POWRange::new(0, 20480));
println!("{}", challenge.solve_singlethread());
{
let num = Num::new(473823);
let time = Instant::now();
hash_num(num);
println!("Simple hash of {} took {} millis", u128::from(num), time.elapsed().as_millis());
}
{
let time = Instant::now();
let challenge = POWChallenge::make(POWRange::new(0, 20480));
println!("Solvling {} took {} seconds", challenge.solve_singlethread(), time.elapsed().as_secs_f32());
}
}

View File

@ -28,4 +28,10 @@ impl From<u128> for Num {
fn from(number: u128) -> Self {
Num { number }
}
}
impl From<Num> for u128 {
fn from(value: Num) -> Self {
value.number
}
}