From 26604ce88fcb9c0e08b5c3b66606f2c6d4418a05 Mon Sep 17 00:00:00 2001 From: Abner Kaizer Date: Sat, 31 Jul 2021 19:36:56 -0300 Subject: [PATCH 1/4] Adding .cargo and release flags --- .cargo/config.toml | 3 +++ Cargo.toml | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 .cargo/config.toml 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..f1d61c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,14 @@ edition = "2018" tokio = { version = "0.3", features = ["full"] } image = "0.23.12" rand = "0.7.3" + +[profile.release] +opt-level = 3 +debug = false +debug-assertions = false +overflow-checks = false +lto = true +panic = 'unwind' +incremental = false +codegen-units = 16 +rpath = false From 9d62a3340dca936d00e98d4969230cf42633f688 Mon Sep 17 00:00:00 2001 From: Abner Kaizer Date: Sat, 31 Jul 2021 19:47:23 -0300 Subject: [PATCH 2/4] Updating version of dependencies --- Cargo.toml | 6 +++--- src/main.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f1d61c8..c6f883d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,9 @@ edition = "2018" # 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.9.0", features = ["full"] } +image = "0.23.14" +rand = "0.8.4" [profile.release] opt-level = 3 diff --git a/src/main.rs b/src/main.rs index 0c8ed6e..9cb4007 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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.gen_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.gen_range(0. .. 1.0)) / (HEIGHT as f64)) + py; let (m_res, m_iter) = mandelbrot_iter(nx, ny); paint(m_res, m_iter) }) From 7b34acf31e9a0bce37c73eee4cc185f17ed1895e Mon Sep 17 00:00:00 2001 From: Abner Kaizer Date: Sun, 2 Feb 2025 18:01:14 -0300 Subject: [PATCH 3/4] chore: updated dependencies versions --- Cargo.toml | 13 +++++++------ src/main.rs | 12 ++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c6f883d..fbb12ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,22 +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 = "1.9.0", features = ["full"] } -image = "0.23.14" -rand = "0.8.4" +tokio = { version = "1.43.0", features = ["full"] } +image = "0.25.5" +rand = "0.9.0" [profile.release] opt-level = 3 debug = false debug-assertions = false overflow-checks = false -lto = true +codegen-units = 1 +lto = "fat" panic = 'unwind' incremental = false -codegen-units = 16 rpath = false +strip = true \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9cb4007..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) }) From 6d97fe0c264b9db434321f50cb41939d3ee1a438 Mon Sep 17 00:00:00 2001 From: Abner Kaizer Date: Mon, 3 Feb 2025 16:16:58 -0300 Subject: [PATCH 4/4] chore: specified used tokio features --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fbb12ec..5ca7759 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -tokio = { version = "1.43.0", features = ["full"] } +tokio = { version = "1.43.0", features = ["rt-multi-thread", "sync", "macros"] } image = "0.25.5" rand = "0.9.0"