progs/perf: add scons support, get working under mingw

This commit is contained in:
Keith Whitwell
2009-09-17 12:08:04 +01:00
parent 21caa29fbd
commit e95a3a23dc
9 changed files with 80 additions and 24 deletions

View File

@@ -10,4 +10,5 @@ SConscript([
'vpglsl/SConscript',
'fp/SConscript',
'wgl/SConscript',
'perf/SConscript',
])

26
progs/perf/SConscript Normal file
View File

@@ -0,0 +1,26 @@
Import('env')
if not env['GLUT']:
Return()
env = env.Clone()
env.Prepend(LIBS = ['$GLUT_LIB'])
progs = [
'drawoverhead',
'teximage',
'vbo',
'vertexrate',
]
for prog in progs:
env.Program(
target = prog,
source = [
prog + '.c',
'common.c',
'glmain.c',
]
)

View File

@@ -26,6 +26,28 @@
#include "common.h"
#include "glmain.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
/* Need to add a fflush windows console with mingw, otherwise nothing
* shows up until program exit. May want to add logging here.
*/
void
perf_printf(const char *format, ...)
{
va_list ap;
va_start(ap, format);
fflush(stdout);
vfprintf(stdout, format, ap);
fflush(stdout);
va_end(ap);
}
/**
* Run function 'f' for enough iterations to reach a steady state.
@@ -52,7 +74,7 @@ PerfMeasureRate(PerfRateFunc f)
subiters *= 2;
} while (t1 - t0 < 0.1 * minDuration);
}
/*printf("initial subIters = %u\n", subiters);*/
/*perf_printf("initial subIters = %u\n", subiters);*/
while (1) {
const double t0 = PerfGetTime();
@@ -68,7 +90,7 @@ PerfMeasureRate(PerfRateFunc f)
rate = iters / (t1 - t0);
if (0)
printf("prevRate %f rate %f ratio %f iters %u\n",
perf_printf("prevRate %f rate %f ratio %f iters %u\n",
prevRate, rate, rate/prevRate, iters);
/* Try and speed the search up by skipping a few steps:
@@ -86,7 +108,7 @@ PerfMeasureRate(PerfRateFunc f)
}
if (0)
printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
perf_printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
return rate;
}

View File

@@ -31,5 +31,9 @@ extern double
PerfMeasureRate(PerfRateFunc f);
extern void
perf_printf(const char *format, ...);
#endif /* COMMON_H */

View File

@@ -116,17 +116,18 @@ PerfDraw(void)
double rate0, rate1, rate2, overhead;
rate0 = PerfMeasureRate(DrawNoStateChange);
printf(" Draw only: %.1f draws/second\n", rate0);
perf_printf(" Draw only: %.1f draws/second\n", rate0);
rate1 = PerfMeasureRate(DrawNopStateChange);
overhead = 1000.0 * (1.0 / rate1 - 1.0 / rate0);
printf(" Draw w/ nop state change: %.1f draws/sec (overhead: %f ms/draw)\n",
rate1, overhead);
perf_printf(" Draw w/ nop state change: %.1f draws/sec (overhead: %f ms/draw)\n",
rate1, overhead);
rate2 = PerfMeasureRate(DrawStateChange);
overhead = 1000.0 * (1.0 / rate2 - 1.0 / rate0);
printf(" Draw w/ state change: %.1f draws/sec (overhead: %f ms/draw)\n",
rate2, overhead);
perf_printf(" Draw w/ state change: %.1f draws/sec (overhead: %f ms/draw)\n",
rate2, overhead);
exit(0);
}

View File

@@ -26,7 +26,6 @@
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

View File

@@ -50,8 +50,11 @@ static const struct vertex vertices[1] = {
{ 0.0, 0.0, 0.5, 0.5 },
};
#if 0
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
#else
#define VOFFSET(F) ((void *) &((struct vertex *)NULL)->F)
#endif
/** Called from test harness/main */
void
@@ -196,10 +199,10 @@ PerfDraw(void)
mbPerSec = rate * bytesPerImage / (1024.0 * 1024.0);
printf(" glTex%sImage2D(%s %d x %d): "
"%.1f images/sec, %.1f MB/sec\n",
(subImage ? "Sub" : ""),
SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);
perf_printf(" glTex%sImage2D(%s %d x %d): "
"%.1f images/sec, %.1f MB/sec\n",
(subImage ? "Sub" : ""),
SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);
free(TexImage);
}

View File

@@ -127,8 +127,8 @@ PerfDraw(void)
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);
printf(" glBuffer%sDataARB(size = %d): %.1f MB/sec\n",
(sub ? "Sub" : ""), VBOSize, mbPerSec);
perf_printf(" glBuffer%sDataARB(size = %d): %.1f MB/sec\n",
(sub ? "Sub" : ""), VBOSize, mbPerSec);
free(VBOData);
}

View File

@@ -237,35 +237,35 @@ PerfDraw(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);
perf_printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);
rate = PerfMeasureRate(DrawImmediate);
rate *= NumVerts;
printf(" Immediate mode: %.1f verts/sec\n", rate);
perf_printf(" Immediate mode: %.1f verts/sec\n", rate);
rate = PerfMeasureRate(DrawArraysMem);
rate *= NumVerts;
printf(" glDrawArrays: %.1f verts/sec\n", rate);
perf_printf(" glDrawArrays: %.1f verts/sec\n", rate);
rate = PerfMeasureRate(DrawArraysVBO);
rate *= NumVerts;
printf(" VBO glDrawArrays: %.1f verts/sec\n", rate);
perf_printf(" VBO glDrawArrays: %.1f verts/sec\n", rate);
rate = PerfMeasureRate(DrawElementsMem);
rate *= NumVerts;
printf(" glDrawElements: %.1f verts/sec\n", rate);
perf_printf(" glDrawElements: %.1f verts/sec\n", rate);
rate = PerfMeasureRate(DrawElementsBO);
rate *= NumVerts;
printf(" VBO glDrawElements: %.1f verts/sec\n", rate);
perf_printf(" VBO glDrawElements: %.1f verts/sec\n", rate);
rate = PerfMeasureRate(DrawRangeElementsMem);
rate *= NumVerts;
printf(" glDrawRangeElements: %.1f verts/sec\n", rate);
perf_printf(" glDrawRangeElements: %.1f verts/sec\n", rate);
rate = PerfMeasureRate(DrawRangeElementsBO);
rate *= NumVerts;
printf(" VBO glDrawRangeElements: %.1f verts/sec\n", rate);
perf_printf(" VBO glDrawRangeElements: %.1f verts/sec\n", rate);
exit(0);
}