From be74b0e517860c3e083b447b65b1d5ddf63b5414 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Thu, 13 Feb 2020 09:52:22 +0100 Subject: [PATCH] Change project name --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- README.md | 2 +- src/main.rs | 11 +---------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78ac016..b18b47f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,6 +82,14 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "euler-10" +version = "0.1.0" +dependencies = [ + "may 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "generator" version = "0.6.19" @@ -186,14 +194,6 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "primes" -version = "0.1.0" -dependencies = [ - "may 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "redox_syscall" version = "0.1.56" diff --git a/Cargo.toml b/Cargo.toml index fd61dfb..c4b4e03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "primes" +name = "euler-10" version = "0.1.0" authors = ["trivernis "] edition = "2018" diff --git a/README.md b/README.md index 3d14457..f21c659 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,5 @@ A simple program that calculates prime numbers with multithreading. The resultin cargo build --release # run -./target/release/primes [] +./target/release/euler-10 [] ``` \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 559fdac..6dcc538 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,26 +1,17 @@ use may::go; use may::sync::mpmc::{channel, Sender}; use num_cpus; -use std::env; use std::time::{Instant, Duration}; fn main() { may::config().set_workers(num_cpus::get()); let (tx, rx) = channel::(); let num_threads: u16 = num_cpus::get() as u16; - let mut start: u64 = 1; - let args: Vec = env::args().collect(); - if args.len() > 1 { - start = args[1].parse::().unwrap(); - } - if &start % 2 == 0 { - start += 1; - } println!("Starting {} threads", num_threads); for i in 0u16..num_threads { let tx = tx.clone(); go!(move || { - get_primes(start + (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); }