[ADD] Add measurement for chapters
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
|
// 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
|
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include <raytracing.h>
|
#include <raytracing.h>
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
#define kWallZ 10
|
#define kWallZ 10
|
||||||
|
|
||||||
using namespace Raytracer;
|
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 main(void)
|
||||||
{
|
{
|
||||||
|
int the_ret;
|
||||||
|
chrono::time_point<chrono::high_resolution_clock> the_start, the_end;
|
||||||
|
|
||||||
printf("Chapter 05 example.\n");
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
|
// 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
|
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include <raytracing.h>
|
#include <raytracing.h>
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
#define kWallZ 10
|
#define kWallZ 10
|
||||||
|
|
||||||
using namespace Raytracer;
|
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 main(void)
|
||||||
{
|
{
|
||||||
|
int the_ret;
|
||||||
|
chrono::time_point<chrono::high_resolution_clock> the_start, the_end;
|
||||||
|
|
||||||
printf("Chapter 06 example.\n");
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
|
// 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
|
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include <raytracing.h>
|
#include <raytracing.h>
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
using namespace Raytracer;
|
using namespace Raytracer;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -43,6 +45,8 @@ int main(void)
|
|||||||
Canvas the_canvas;
|
Canvas the_canvas;
|
||||||
Sphere *the_floor, *the_left_wall, *the_right_wall;
|
Sphere *the_floor, *the_left_wall, *the_right_wall;
|
||||||
Sphere *the_middle, *the_right, *the_left;
|
Sphere *the_middle, *the_right, *the_left;
|
||||||
|
chrono::time_point<chrono::high_resolution_clock> the_start, the_end;
|
||||||
|
|
||||||
printf("Chapter 07 example.\n");
|
printf("Chapter 07 example.\n");
|
||||||
|
|
||||||
// Floor is an extremely flattened sphere with a matte texture.
|
// Floor is an extremely flattened sphere with a matte texture.
|
||||||
@@ -100,9 +104,14 @@ int main(void)
|
|||||||
the_camera.set_transform(
|
the_camera.set_transform(
|
||||||
Matrix::view_transform(Tuple::Point(0, 1.5, -5), Tuple::Point(0, 1, 0), Tuple::Vector(0, 1, 0)));
|
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_canvas = the_camera.render(the_world);
|
||||||
|
the_end = chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
the_canvas.save_to_file("chapter07.ppm");
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user