Finalize changes to profiler
This commit is contained in:
parent
9793e1cfd9
commit
8cfa97632f
|
@ -1239,6 +1239,8 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
|
||||||
glBlendFunc(blendSrc, blendDst);
|
glBlendFunc(blendSrc, blendDst);
|
||||||
(blendEnabled) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
(blendEnabled) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
||||||
(depthEnabled) ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
|
(depthEnabled) ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
PROFILER_POP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
|
void APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
|
||||||
|
|
|
@ -152,7 +152,7 @@ void APIENTRY glKosSwapBuffers() {
|
||||||
PROFILER_CHECKPOINT("scene");
|
PROFILER_CHECKPOINT("scene");
|
||||||
PROFILER_POP();
|
PROFILER_POP();
|
||||||
|
|
||||||
if(frame_count++ > 100) {
|
if(++frame_count > 49) {
|
||||||
profiler_print_stats();
|
profiler_print_stats();
|
||||||
frame_count = 0;
|
frame_count = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "profiler.h"
|
#include "profiler.h"
|
||||||
|
#include "private.h"
|
||||||
#ifdef PROFILER_COMPILE
|
#ifdef PROFILER_COMPILE
|
||||||
#include "../containers/aligned_vector.h"
|
#include "../containers/aligned_vector.h"
|
||||||
|
|
||||||
|
@ -132,15 +133,20 @@ void profiler_pop() {
|
||||||
void profiler_print_stats() {
|
void profiler_print_stats() {
|
||||||
if(!PROFILER_ENABLED) return;
|
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;
|
uint16_t i = 0;
|
||||||
for(; i < root->results.size; ++i) {
|
for(; i < root->results.size; ++i) {
|
||||||
ProfilerResult* result = aligned_vector_at(&root->results, i);
|
ProfilerResult* result = aligned_vector_at(&root->results, i);
|
||||||
float ms = ((float) result->total_time_us) / 1000.0f;
|
float ms = ((float) result->total_time_us) / 1000.0f;
|
||||||
float avg = ms / (float) result->total_calls;
|
float avg = ms / (float) result->total_calls;
|
||||||
|
total_ms += ms;
|
||||||
|
|
||||||
fprintf(stderr, "%-60s%-20f%-20f%u\n", result->name, avg, ms, result->total_calls);
|
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
|
#endif
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define PROFILER_COMPILE 1
|
#define PROFILER_COMPILE 1
|
||||||
#ifdef PROFILER_COMPILE
|
#if PROFILER_COMPILE
|
||||||
#define PROFILER_PUSH(S) profiler_push(S)
|
#define PROFILER_PUSH(S) profiler_push(S)
|
||||||
#define PROFILER_CHECKPOINT(P) profiler_checkpoint(P)
|
#define PROFILER_CHECKPOINT(P) profiler_checkpoint(P)
|
||||||
#define PROFILER_POP() profiler_pop()
|
#define PROFILER_POP() profiler_pop()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user