[ADD] Add measurement for chapters

This commit is contained in:
NADAL Jean-Baptiste
2024-02-27 18:18:40 +01:00
parent 429fa3f743
commit 38e34f3b2c
3 changed files with 37 additions and 2 deletions

View File

@@ -26,6 +26,7 @@
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include <chrono>
#include <cstdio>
#include <raytracing.h>
@@ -37,6 +38,7 @@
#define kWallZ 10
using namespace Raytracer;
using namespace std;
/* ------------------------------------------------------------------------- */
@@ -86,6 +88,17 @@ int shadow_sphere(uint8_t a_canvas_pixels, double a_wall_size, uint8_t a_wall_z)
int main(void)
{
int the_ret;
chrono::time_point<chrono::high_resolution_clock> the_start, the_end;
printf("Chapter 05 example.\n");
return shadow_sphere(kImageSize, kWallSize, kWallZ);
the_start = chrono::high_resolution_clock::now();
the_ret = shadow_sphere(kImageSize, kWallSize, kWallZ);
the_end = chrono::high_resolution_clock::now();
chrono::duration<double> the_elapsed_time = the_end - the_start;
printf("Execution Time: %f secondes\n", the_elapsed_time.count());
return the_ret;
}

View File

@@ -26,6 +26,7 @@
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include <chrono>
#include <cstdio>
#include <raytracing.h>
@@ -37,6 +38,7 @@
#define kWallZ 10
using namespace Raytracer;
using namespace std;
/* ------------------------------------------------------------------------- */
@@ -93,6 +95,17 @@ int shadow_sphere(uint8_t a_canvas_pixels, double a_wall_size, uint8_t a_wall_z)
int main(void)
{
int the_ret;
chrono::time_point<chrono::high_resolution_clock> the_start, the_end;
printf("Chapter 06 example.\n");
return shadow_sphere(kImageSize, kWallSize, kWallZ);
the_start = chrono::high_resolution_clock::now();
the_ret = shadow_sphere(kImageSize, kWallSize, kWallZ);
the_end = chrono::high_resolution_clock::now();
chrono::duration<double> the_elapsed_time = the_end - the_start;
printf("Execution Time: %f secondes\n", the_elapsed_time.count());
return the_ret;
}

View File

@@ -26,6 +26,7 @@
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include <chrono>
#include <cstdio>
#include <raytracing.h>
@@ -33,6 +34,7 @@
/* ------------------------------------------------------------------------- */
using namespace Raytracer;
using namespace std;
/* ------------------------------------------------------------------------- */
@@ -43,6 +45,8 @@ int main(void)
Canvas the_canvas;
Sphere *the_floor, *the_left_wall, *the_right_wall;
Sphere *the_middle, *the_right, *the_left;
chrono::time_point<chrono::high_resolution_clock> the_start, the_end;
printf("Chapter 07 example.\n");
// Floor is an extremely flattened sphere with a matte texture.
@@ -100,9 +104,14 @@ int main(void)
the_camera.set_transform(
Matrix::view_transform(Tuple::Point(0, 1.5, -5), Tuple::Point(0, 1, 0), Tuple::Vector(0, 1, 0)));
the_start = chrono::high_resolution_clock::now();
the_canvas = the_camera.render(the_world);
the_end = chrono::high_resolution_clock::now();
the_canvas.save_to_file("chapter07.ppm");
chrono::duration<double> the_elapsed_time = the_end - the_start;
printf("Execution Time: %f secondes\n", the_elapsed_time.count());
return 0;
}