Skip to content

Commit fbdfeec

Browse files
committed
added timer for benchmarking
1 parent 08f1b1f commit fbdfeec

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

RaytracingWeekend/RaytracingWeekend.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ void threaded_render(std::vector<color>& output, hittable_list& world, int sampl
5353

5454
int main()
5555
{
56+
57+
auto start = std::chrono::high_resolution_clock::now();
5658
//Camera Settings
5759
point3 lookfrom(13, 2, 3);
5860
point3 lookat(0, 0, 0);
@@ -64,9 +66,9 @@ int main()
6466

6567
//Render Settings
6668
const std::string filename = "render.ppm";
67-
int sample_count = 50;
68-
int max_depth = 20;
69-
const int num_threads = 8;
69+
int sample_count = 100;
70+
int max_depth = 50;
71+
const int num_threads = 16;
7072

7173
// World
7274
hittable_list world = random_scene();
@@ -93,6 +95,8 @@ int main()
9395
{
9496
threads[i].join();
9597
}
98+
const auto elapsed = std::chrono::high_resolution_clock::now() - start;
99+
std::cerr << "Render took: " << std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count() << "ms " << std::endl;
96100

97101
std::cerr << "\nCollecting threads\n";
98102
for (int j = 0; j < cam.image_height*cam.image_width; ++j)
@@ -104,6 +108,9 @@ int main()
104108
}
105109
write_color(output_file, tmp_color / num_threads);
106110
}
111+
112+
const auto elapsed2 = std::chrono::high_resolution_clock::now() - start;
113+
std::cerr << "Render + file write took: " << std::chrono::duration_cast<std::chrono::milliseconds>(elapsed2).count() << "ms " << std::endl;
107114

108115
std::cerr << "\nDone";
109116
}

RaytracingWeekend/camera.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class camera {
2525
lens_radius = aperture / 2;
2626

2727
//Image
28-
image_width = 500;
28+
image_width = 720;
2929
image_height = static_cast<int>(image_width / aspect);
3030

3131
origin = lookfrom;

0 commit comments

Comments
 (0)