Finalize changes to profiler

This commit is contained in:
Hayden K 2019-03-12 18:12:38 -04:00
parent 9793e1cfd9
commit 8cfa97632f
4 changed files with 13 additions and 5 deletions

View File

@ -1239,6 +1239,8 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
glBlendFunc(blendSrc, blendDst);
(blendEnabled) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
(depthEnabled) ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
PROFILER_POP();
}
void APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {

View File

@ -121,7 +121,7 @@ void APIENTRY glKosInit() {
void APIENTRY glKosSwapBuffers() {
static int frame_count = 0;
TRACE();
PROFILER_PUSH(__func__);
@ -152,7 +152,7 @@ void APIENTRY glKosSwapBuffers() {
PROFILER_CHECKPOINT("scene");
PROFILER_POP();
if(frame_count++ > 100) {
if(++frame_count > 49) {
profiler_print_stats();
frame_count = 0;
}

View File

@ -5,6 +5,7 @@
#include <stdio.h>
#include "profiler.h"
#include "private.h"
#ifdef PROFILER_COMPILE
#include "../containers/aligned_vector.h"
@ -132,15 +133,20 @@ void profiler_pop() {
void profiler_print_stats() {
if(!PROFILER_ENABLED) return;
fprintf(stderr, "%-60s%-20s%-20s%-20s\n", "Path", "Average", "Total", "Calls");
fprintf(stderr, "%-40s%-20s%-20s%-20s%-20s\n", "Path", "Time(ms)", "Average", "Total", "Calls");
float total_ms = 0;
float fps = 0;
uint16_t i = 0;
for(; i < root->results.size; ++i) {
ProfilerResult* result = aligned_vector_at(&root->results, i);
float ms = ((float) result->total_time_us) / 1000.0f;
float avg = ms / (float) result->total_calls;
total_ms += ms;
fprintf(stderr, "%-60s%-20f%-20f%u\n", result->name, avg, ms, result->total_calls);
}
total_ms/=((ProfilerResult*)aligned_vector_at(&root->results, i-1))->total_calls;
fps = 1000/total_ms;
fprintf(stderr, "%-10s%-10f%-10s%-10f\n", "Time(ms)", total_ms, "FPS", fps);
}
#endif

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#define PROFILER_COMPILE 1
#ifdef PROFILER_COMPILE
#if PROFILER_COMPILE
#define PROFILER_PUSH(S) profiler_push(S)
#define PROFILER_CHECKPOINT(P) profiler_checkpoint(P)
#define PROFILER_POP() profiler_pop()