diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..d5502cf --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "x86_64-unknown-linux-musl" +rustflags = ["-C","target-cpu=native"] diff --git a/Cargo.toml b/Cargo.toml index 8d82553..3c89e82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,11 +2,23 @@ name = "fractal" version = "0.1.0" authors = ["alexandre "] -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -tokio = { version = "0.3", features = ["full"] } -image = "0.23.12" -rand = "0.7.3" +tokio = { version = "1.43.0", features = ["rt-multi-thread", "sync", "macros"] } +image = "0.25.5" +rand = "0.9.0" + +[profile.release] +opt-level = 3 +debug = false +debug-assertions = false +overflow-checks = false +codegen-units = 1 +lto = "fat" +panic = 'abort' +incremental = false +rpath = false +strip = true diff --git a/src/main.rs b/src/main.rs index 0c8ed6e..ef06d68 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ mod color; use image; -use rand::{thread_rng, Rng}; +use rand::{rng, Rng}; use tokio::sync::mpsc; -const WIDTH: u32 = 1024; -const HEIGHT: u32 = 1024; +const WIDTH: u32 = 3840; +const HEIGHT: u32 = 2160; const BUF_SIZE: u32 = WIDTH * HEIGHT * 3; const NB_SAMPLES: u32 = 50; const SIZE: f64 = 0.000000001; @@ -55,7 +55,7 @@ fn write_line(buf: &mut Vec, line: &Vec, line_number: u32) { } fn render_line(line_number: u32, px: f64, py: f64) -> (Vec, u32) { - let mut rng = thread_rng(); + let mut rng = rng(); let line_size = WIDTH * 3; let mut line: Vec = vec![0; line_size as usize]; @@ -63,9 +63,9 @@ fn render_line(line_number: u32, px: f64, py: f64) -> (Vec, u32) { for x in 0..WIDTH { let sampled_colours = (0..NB_SAMPLES) .map(|_| { - let nx = SIZE * (((x as f64) + rng.gen_range(0., 1.0)) / (WIDTH as f64)) + px; + let nx = SIZE * (((x as f64) + rng.random_range(0. .. 1.0)) / (WIDTH as f64)) + px; let ny = - SIZE * (((line_number as f64) + rng.gen_range(0., 1.0)) / (HEIGHT as f64)) + py; + SIZE * (((line_number as f64) + rng.random_range(0. .. 1.0)) / (HEIGHT as f64)) + py; let (m_res, m_iter) = mandelbrot_iter(nx, ny); paint(m_res, m_iter) })