diff options
-rw-r--r-- | progs/SConscript | 1 | ||||
-rw-r--r-- | progs/perf/SConscript | 26 | ||||
-rw-r--r-- | progs/perf/common.c | 28 | ||||
-rw-r--r-- | progs/perf/common.h | 4 | ||||
-rw-r--r-- | progs/perf/drawoverhead.c | 11 | ||||
-rw-r--r-- | progs/perf/glmain.h | 1 | ||||
-rw-r--r-- | progs/perf/teximage.c | 13 | ||||
-rw-r--r-- | progs/perf/vbo.c | 4 | ||||
-rw-r--r-- | progs/perf/vertexrate.c | 16 |
9 files changed, 80 insertions, 24 deletions
diff --git a/progs/SConscript b/progs/SConscript index 620dd30e69..66eaf9e541 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -10,4 +10,5 @@ SConscript([ 'vpglsl/SConscript', 'fp/SConscript', 'wgl/SConscript', + 'perf/SConscript', ]) diff --git a/progs/perf/SConscript b/progs/perf/SConscript new file mode 100644 index 0000000000..c019dc95b0 --- /dev/null +++ b/progs/perf/SConscript @@ -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', + ] + ) + diff --git a/progs/perf/common.c b/progs/perf/common.c index a50fc11cca..695b8a99d9 100644 --- a/progs/perf/common.c +++ b/progs/perf/common.c @@ -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; } diff --git a/progs/perf/common.h b/progs/perf/common.h index 8b6091530d..85db678c64 100644 --- a/progs/perf/common.h +++ b/progs/perf/common.h @@ -31,5 +31,9 @@ extern double PerfMeasureRate(PerfRateFunc f); +extern void +perf_printf(const char *format, ...); + + #endif /* COMMON_H */ diff --git a/progs/perf/drawoverhead.c b/progs/perf/drawoverhead.c index 8c99804d34..a1d5febf19 100644 --- a/progs/perf/drawoverhead.c +++ b/progs/perf/drawoverhead.c @@ -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);
}
diff --git a/progs/perf/glmain.h b/progs/perf/glmain.h index 50480a80c0..fe11d7235e 100644 --- a/progs/perf/glmain.h +++ b/progs/perf/glmain.h @@ -26,7 +26,6 @@ #define GL_GLEXT_PROTOTYPES #include <GL/glew.h> -#include <stdio.h> #include <stdlib.h> #include <math.h> diff --git a/progs/perf/teximage.c b/progs/perf/teximage.c index b6d4f644de..8727536922 100644 --- a/progs/perf/teximage.c +++ b/progs/perf/teximage.c @@ -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);
}
diff --git a/progs/perf/vbo.c b/progs/perf/vbo.c index 8545a33b7e..4ed6a88fcc 100644 --- a/progs/perf/vbo.c +++ b/progs/perf/vbo.c @@ -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);
}
diff --git a/progs/perf/vertexrate.c b/progs/perf/vertexrate.c index f7e02624cc..d3dd0c200f 100644 --- a/progs/perf/vertexrate.c +++ b/progs/perf/vertexrate.c @@ -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);
}
|