Browse Source

added basic profiling

Iver 2 months ago
parent
commit
aa00d40680
4 changed files with 30 additions and 5 deletions
  1. BIN
      builds/librasteriver.so
  2. BIN
      builds/main.bin
  3. 3 3
      src/launch program/main.c
  4. 27 2
      src/main/main.c

BIN
builds/librasteriver.so


BIN
builds/main.bin


+ 3 - 3
src/launch program/main.c

@@ -4,8 +4,8 @@
 int main(){
     RI_context* context = RI_get_context();
     
-    context->window.width = 600;
-    context->window.height = 600;
+    context->window.width = 700;
+    context->window.height = 700;
     context->window.title = "This is RasterIver 3.0!!!!!!!";
     
     if (RI_init() != 0){
@@ -40,7 +40,7 @@ int main(){
     scene->actors[0] = cube;
     scene->actors[1] = triangle;
 
-    scene->length_of_actors_array = 2;
+    scene->length_of_actors_array = 1;
 
     long int start, end;
     double fps = 0;

+ 27 - 2
src/main/main.c

@@ -4,6 +4,7 @@
 #include <SDL2/SDL.h>
 #include "../headers/rasteriver.h"
 #include "../headers/memory.h"
+#include <time.h>
 
 RI_context context;
 
@@ -80,6 +81,10 @@ RI_scene *RI_new_scene(){
 }
 
 RI_mesh *RI_load_mesh(char *filename, RI_actor *actor){
+    clock_t start_time, end_time;
+    
+    start_time = clock();
+
     int previous_face_count = context.opencl.face_count;
     int previous_vertecies_count = context.opencl.vertex_count;
     int previous_normals_count = context.opencl.normal_count;
@@ -308,9 +313,17 @@ RI_mesh *RI_load_mesh(char *filename, RI_actor *actor){
     }
 
     fclose(file);
+    
+    end_time = clock();
+
+    debug("Done! loading mesh took %lf seconds", (double)(end_time - start_time) / CLOCKS_PER_SEC);
 }
 
 void RI_render(RI_texture *target_texture, RI_scene *scene){
+    clock_t start_time, end_time;
+    
+    start_time = clock();
+    
     if (!target_texture){
         target_texture = context.sdl.frame_buffer;
     }
@@ -450,7 +463,7 @@ void RI_render(RI_texture *target_texture, RI_scene *scene){
         clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(end), &end, NULL);
 
         double ns = (double)(end - start);
-        printf("actor #%d's transformation kernel: %f ms\n", actor_index, ns / 1e6);
+        printf("actor #%d's transformation kernel took %f seconds\n", actor_index, ns / 1e6);
         
         debug("done");
     
@@ -502,12 +515,20 @@ void RI_render(RI_texture *target_texture, RI_scene *scene){
     clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(end), &end, NULL);
 
     double ns = (double)(end - start);
-    printf("rasterization kernel: %f ms\n", ns / 1e6);
+    printf("rasterization kernel took %f seconds\n", ns / 1e6);
 
     debug("done");
+
+    end_time = clock();
+
+    debug("Done! rendering took %lf seconds", (double)(end_time - start_time) / CLOCKS_PER_SEC);
 }
 
 void RI_tick(){
+    clock_t start_time, end_time;
+    
+    start_time = clock();
+    
     SDL_Event event;
 
     while (SDL_PollEvent(&event)){
@@ -535,6 +556,10 @@ void RI_tick(){
 
     ++context.current_frame;
 
+    end_time = clock();
+
+    debug("Done! ticking took %lf seconds", (double)(end_time - start_time) / CLOCKS_PER_SEC);
+
     return;
 }