Skip to content

Commit

Permalink
Updated Julia and Rust to render image to simplify benchmarking, use …
Browse files Browse the repository at this point in the history
…"ray time --name julia , ray time --name rust to get average results of the multiple runs
  • Loading branch information
edin committed May 3, 2021
1 parent e8794d0 commit b580e02
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
2 changes: 0 additions & 2 deletions julia/RayTracer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ function Render(scene::Scene)
return image
end

scene = Scene()
image = Render(scene)
@time begin
scene = Scene()
image = Render(scene)
Expand Down
2 changes: 1 addition & 1 deletion projects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<Project Path="typescript" Language="TypeScript">
<Command Name="Default">
<Run Process="ts-node" Arguments="RayTracer.ts" />
<Run Process="cmd" Arguments="/c ts-node RayTracer.ts" />
</Command>
</Project>

Expand Down
19 changes: 4 additions & 15 deletions rust/src/ray_tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ fn main() {

let mut image = Image::new(width, height);

let n = 100;
let engine = RayTracerEngine {
max_depth: 5,
scene: Scene::new(),
Expand All @@ -538,26 +537,16 @@ fn main() {
let now = Instant::now();

if is_parallel {
println!("Parallel!");

for _ in 0..n {
engine.parallel_render(&mut image, width, height);
}
engine.parallel_render(&mut image, width, height);
} else {
println!("Not parallel!");

for _ in 0..n {
engine.render(&mut image, width, height);
}
engine.render(&mut image, width, height);
}

let t = now.elapsed().as_millis();
let version = if is_parallel { "[Paralel]" } else { "" };

println!(
"total time for {:?} iterations = {:?} ms, avg time = {:?} ms",
n,
t,
t / n
"Completed in {:?} ms {}", t, version
);

image.save("RayTracer.bmp");
Expand Down
2 changes: 1 addition & 1 deletion typescript/RayTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,6 @@ class BitmapImage {
let rayTracer = new RayTracer();
rayTracer.render(defaultScene(), image);
image.saveSync("typescript-ray.bmp")
const time = performance.now() - start;
const time = Math.round(performance.now() - start);
console.log(`Completed in ${time} ms`)
})();

0 comments on commit b580e02

Please sign in to comment.