Remove printing of numbers to increase speed

master
Trivernis 5 years ago
parent b37c872a79
commit 738a69b17f

@ -13,7 +13,6 @@ fn main() {
go!(move || { go!(move || {
get_primes(1 + (2 * &i) as u64, (&num_threads * 2) as u64, 2_000_000, &tx); get_primes(1 + (2 * &i) as u64, (&num_threads * 2) as u64, 2_000_000, &tx);
}); });
println!("Started thread {}", i);
} }
let time_start = Instant::now(); let time_start = Instant::now();
let mut primes: Vec<u64> = vec![]; let mut primes: Vec<u64> = vec![];
@ -26,7 +25,6 @@ fn main() {
Err(_) => break, Err(_) => break,
Ok(prime) => { Ok(prime) => {
primes.push(prime); primes.push(prime);
println!("\r{: <30}", prime);
} }
} }
} }
@ -34,7 +32,6 @@ fn main() {
for prime in primes { for prime in primes {
prime_sum += prime as u128; prime_sum += prime as u128;
} }
println!();
println!("Prime Sum: {}", prime_sum); println!("Prime Sum: {}", prime_sum);
println!("Solution took: {} ms", time_start.elapsed().as_millis()) println!("Solution took: {} ms", time_start.elapsed().as_millis())
} }
@ -42,7 +39,6 @@ fn main() {
/// Calculates primes and increases by incr with every iteration /// Calculates primes and increases by incr with every iteration
/// Resulting prime numbers are sent via the tx sender. /// Resulting prime numbers are sent via the tx sender.
fn get_primes(start: u64, incr: u64, stop_after: u64, tx: &Sender<u64>) { fn get_primes(start: u64, incr: u64, stop_after: u64, tx: &Sender<u64>) {
println!("Hi, I'm a thread.");
let mut num = start; let mut num = start;
while num < stop_after { while num < stop_after {
let mut is_prime = true; let mut is_prime = true;

Loading…
Cancel
Save