Add extended debug logging to check on threads

master
trivernis 5 years ago
parent ddb7897657
commit 22e7013e2d

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="true" />
</component>
<component name="ProjectNotificationSettings">
<option name="askShowProject" value="false" />
</component>
</project>

@ -1,11 +1,11 @@
use may::go;
use may::sync::mpmc::{channel, Sender};
use num_cpus; use num_cpus;
use std::fs::{OpenOptions};
use std::io::prelude::*;
use std::env; use std::env;
use std::time::{Instant}; use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::BufWriter; use std::io::BufWriter;
use may::sync::mpmc::{channel, Sender}; use std::time::Instant;
use may::go;
fn main() { fn main() {
may::config().set_workers(num_cpus::get()); may::config().set_workers(num_cpus::get());
@ -40,7 +40,10 @@ fn main() {
let prime = rx.recv().unwrap(); let prime = rx.recv().unwrap();
prime_count += 1; prime_count += 1;
println!("\r{: <30}", prime); println!("\r{: <30}", prime);
print!("{} Primes/s", prime_count as f64/time_start.elapsed().as_secs_f64()); print!(
"{} Primes/s",
prime_count as f64 / time_start.elapsed().as_secs_f64()
);
if let Err(e) = buffer.write(&format!("{}\n", prime).into_bytes()) { if let Err(e) = buffer.write(&format!("{}\n", prime).into_bytes()) {
panic!(e); panic!(e);
} }
@ -48,6 +51,7 @@ fn main() {
} }
fn get_primes(start: u64, incr: u64, tx: &Sender<u64>) { fn get_primes(start: u64, incr: u64, tx: &Sender<u64>) {
println!("Hi, I'm a thread.");
let mut num = start; let mut num = start;
loop { loop {
let mut is_prime = true; let mut is_prime = true;

Loading…
Cancel
Save