Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Time-a-function/Rust/time-a-function.rust
Normal file
24
Task/Time-a-function/Rust/time-a-function.rust
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// 20210224 Rust programming solution
|
||||
|
||||
use rand::Rng;
|
||||
use std::time::{Instant};
|
||||
|
||||
fn custom_function() {
|
||||
|
||||
let mut i = 0;
|
||||
let mut rng = rand::thread_rng();
|
||||
let n1: f32 = rng.gen();
|
||||
|
||||
while i < ( 1000000 + 1000000 * ( n1.log10() as i32 ) ) {
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
let start = Instant::now();
|
||||
custom_function();
|
||||
let duration = start.elapsed();
|
||||
|
||||
println!("Time elapsed in the custom_function() is : {:?}", duration);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue