|
|
@@ -1,5 +1,7 @@
|
|
1
|
1
|
extern crate clap;
|
|
2
|
2
|
extern crate time;
|
|
|
3
|
+
|
|
|
4
|
+use time::get_time;
|
|
3
|
5
|
use clap::{Arg, App, SubCommand};
|
|
4
|
6
|
use std::process;
|
|
5
|
7
|
mod hasher_sha256;
|
|
|
@@ -9,6 +11,7 @@ pub fn main() {
|
|
9
|
11
|
let matches = create_app().get_matches();
|
|
10
|
12
|
let base = matches.value_of("base").unwrap_or("1");
|
|
11
|
13
|
let diff = matches.value_of("difficulty").unwrap_or("1");
|
|
|
14
|
+ let mut time_measurement = false;
|
|
12
|
15
|
|
|
13
|
16
|
println!("Using base: {}", base);
|
|
14
|
17
|
println!("Using difficulty: {}", diff);
|
|
|
@@ -18,12 +21,20 @@ pub fn main() {
|
|
18
|
21
|
process::exit(1)
|
|
19
|
22
|
}
|
|
20
|
23
|
|
|
|
24
|
+ if let Some(_) = matches.subcommand {
|
|
|
25
|
+ time_measurement = true;
|
|
|
26
|
+ }
|
|
|
27
|
+
|
|
21
|
28
|
match base.parse::<usize>() {
|
|
22
|
29
|
Ok(b) => {
|
|
23
|
30
|
println!("Please wait...");
|
|
|
31
|
+ let start = get_time();
|
|
24
|
32
|
for n in 0..<usize>::max_value() {
|
|
25
|
33
|
if let Some(x) = hash256::verify_product(b, n, &diff.to_string()) {
|
|
|
34
|
+ let end = get_time();
|
|
|
35
|
+ let diff = end - start;
|
|
26
|
36
|
println!("Number: {} --> hash: {}", x.number, x.hash);
|
|
|
37
|
+ println!("(Duration {}s / {}ms / {}us)", diff.num_seconds(), diff.num_milliseconds(), diff.num_microseconds().unwrap_or(0));
|
|
27
|
38
|
process::exit(0)
|
|
28
|
39
|
}
|
|
29
|
40
|
}
|