[PATCH] Eliminate per-test timing calibration.
Adam Jackson
ajax at redhat.com
Thu Jan 7 11:54:29 PST 2010
Instead, use setitimer() to receive a SIGALRM after the requested number
of seconds elapses, and change the tests to report back the true number
of iterations.
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
do_arcs.c | 12 ++++--
do_blt.c | 102 ++++++++++++++++++++++++++++++++++++-------------------
do_complex.c | 12 ++++--
do_dots.c | 6 ++-
do_lines.c | 6 ++-
do_movewin.c | 24 +++++++++----
do_rects.c | 12 ++++--
do_segs.c | 6 ++-
do_simple.c | 24 +++++++++----
do_text.c | 42 +++++++++++++++--------
do_traps.c | 18 ++++++---
do_tris.c | 12 ++++--
do_valgc.c | 6 ++-
do_windows.c | 21 ++++++++---
x11perf.c | 57 +++++++++++++++++++++++--------
x11perf.h | 106 +++++++++++++++++++++++++++++++++-------------------------
16 files changed, 304 insertions(+), 162 deletions(-)
diff --git a/do_arcs.c b/do_arcs.c
index 5c5f1ba..f9b05a2 100644
--- a/do_arcs.c
+++ b/do_arcs.c
@@ -451,7 +451,7 @@ InitWideDoubleDashedEllipses(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoArcs(XParms xp, Parms p, int reps)
{
int i;
@@ -466,11 +466,13 @@ DoArcs(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoFilledArcs(XParms xp, Parms p, int reps)
{
int i;
@@ -485,8 +487,10 @@ DoFilledArcs(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_blt.c b/do_blt.c
index 2834392..0d3cd3e 100644
--- a/do_blt.c
+++ b/do_blt.c
@@ -69,7 +69,7 @@ InitScroll(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoScroll(XParms xp, Parms p, int reps)
{
int i, size, x, y, xorg, yorg, delta;
@@ -106,8 +106,10 @@ DoScroll(XParms xp, Parms p, int reps)
x = xorg;
}
}
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -122,6 +124,8 @@ EndScroll(XParms xp, Parms p)
{
}
+static int nsegs;
+
static void
InitCopyLocations(XParms xp, Parms p, int reps)
{
@@ -129,6 +133,8 @@ InitCopyLocations(XParms xp, Parms p, int reps)
int xinc, yinc;
int width, height;
+ nsegs = reps > 50000 ? 50000 : reps;
+
/* Try to exercise all alignments of src and destination equally, as well
as all 4 top-to-bottom/bottom-to-top, left-to-right, right-to-left
copying directions. Computation done here just to make sure slow
@@ -146,9 +152,9 @@ InitCopyLocations(XParms xp, Parms p, int reps)
x2 = width;
y2 = height;
- segsa = (XSegment *)malloc(reps * sizeof(XSegment));
- segsb = (XSegment *)malloc(reps * sizeof(XSegment));
- for (i = 0; i != reps; i++) {
+ segsa = (XSegment *)malloc(nsegs * sizeof(XSegment));
+ segsb = (XSegment *)malloc(nsegs * sizeof(XSegment));
+ for (i = 0; i != nsegs; i++) {
segsa[i].x1 = x1;
segsa[i].y1 = y1;
segsa[i].x2 = x2;
@@ -228,14 +234,16 @@ InitPutImage(XParms xp, Parms p, int reps)
return reps;
}
-static void
+static int
CopyArea(XParms xp, Parms p, int reps, Drawable src, Drawable dst)
{
int i, size;
XSegment *sa, *sb;
size = p->special;
- for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+ for (i = 0; i != reps; i++) {
+ sa = segsa + (i % nsegs);
+ sb = segsb + (i % nsegs);
XCopyArea(xp->d, src, dst, xp->fggc,
sa->x1, sa->y1, size, size, sa->x2, sa->y2);
XCopyArea(xp->d, src, dst, xp->fggc,
@@ -244,37 +252,41 @@ CopyArea(XParms xp, Parms p, int reps, Drawable src, Drawable dst)
sb->x2, sb->y2, size, size, sb->x1, sb->y1);
XCopyArea(xp->d, src, dst, xp->fggc,
sb->x1, sb->y1, size, size, sb->x2, sb->y2);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoCopyWinWin(XParms xp, Parms p, int reps)
{
- CopyArea(xp, p, reps, xp->w, xp->w);
+ return CopyArea(xp, p, reps, xp->w, xp->w);
}
-void
+int
DoCopyPixWin(XParms xp, Parms p, int reps)
{
- CopyArea(xp, p, reps, pix, xp->w);
+ return CopyArea(xp, p, reps, pix, xp->w);
}
-void
+int
DoCopyWinPix(XParms xp, Parms p, int reps)
{
- CopyArea(xp, p, reps, xp->w, pix);
+ int i = CopyArea(xp, p, reps, xp->w, pix);
xp->p = pix; /* HardwareSync will now sync on pixmap */
+ return i;
}
-void
+int
DoCopyPixPix(XParms xp, Parms p, int reps)
{
- CopyArea(xp, p, reps, pix, pix);
+ int i = CopyArea(xp, p, reps, pix, pix);
xp->p = pix; /* HardwareSync will now sync on pixmap */
+ return i;
}
-void
+int
DoGetImage(XParms xp, Parms p, int reps)
{
int i, size;
@@ -283,7 +295,9 @@ DoGetImage(XParms xp, Parms p, int reps)
size = p->special;
format = (p->font == NULL) ? ZPixmap : XYPixmap;
- for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+ for (i = 0; i != reps; i++) {
+ sa = segsa + (i % nsegs);
+ sb = segsb + (i % nsegs);
XDestroyImage(image);
image = XGetImage(xp->d, xp->w, sa->x1, sa->y1, size, size,
xp->planemask, format);
@@ -311,18 +325,22 @@ rectangle.
(void) XGetSubImage(xp->d, xp->w, sb->x1, sb->y1, size, size,
xp->planemask, ZPixmap, image, sb->x2, sb->y2);
*/
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoPutImage(XParms xp, Parms p, int reps)
{
int i, size;
XSegment *sa, *sb;
size = p->special;
- for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+ for (i = 0; i != reps; i++) {
+ sa = segsa + (i % nsegs);
+ sb = segsb + (i % nsegs);
XPutImage(xp->d, xp->w, xp->fggc, image,
sa->x1, sa->y1, sa->x2, sa->y2, size, size);
XPutImage(xp->d, xp->w, xp->fggc, image,
@@ -331,8 +349,10 @@ DoPutImage(XParms xp, Parms p, int reps)
sb->x2, sb->y2, sb->x2, sb->y2, size, size);
XPutImage(xp->d, xp->w, xp->fggc, image,
sb->x1, sb->y1, sb->x2, sb->y2, size, size);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
#ifdef MITSHM
@@ -447,14 +467,16 @@ InitShmPutImage(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoShmPutImage(XParms xp, Parms p, int reps)
{
int i, size;
XSegment *sa, *sb;
size = p->special;
- for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+ for (i = 0; i != reps; i++) {
+ sa = segsa + (i % nsegs);
+ sb = segsb + (i % nsegs);
XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
sa->x1, sa->y1, sa->x2, sa->y2, size, size, False);
XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
@@ -463,8 +485,10 @@ DoShmPutImage(XParms xp, Parms p, int reps)
sb->x2, sb->y2, sb->x2, sb->y2, size, size, False);
XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
sb->x1, sb->y1, sb->x2, sb->y2, size, size, False);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -542,14 +566,16 @@ InitCopyPlane(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoCopyPlane(XParms xp, Parms p, int reps)
{
int i, size;
XSegment *sa, *sb;
size = p->special;
- for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+ for (i = 0; i != reps; i++) {
+ sa = segsa + (i % nsegs);
+ sb = segsb + (i % nsegs);
XCopyPlane(xp->d, pix, xp->w, xp->fggc,
sa->x1, sa->y1, size, size, sa->x2, sa->y2, 1);
XCopyPlane(xp->d, pix, xp->w, xp->fggc,
@@ -558,8 +584,10 @@ DoCopyPlane(XParms xp, Parms p, int reps)
sb->x2, sb->y2, size, size, sb->x1, sb->y1, 1);
XCopyPlane(xp->d, pix, xp->w, xp->fggc,
sb->x1, sb->y1, size, size, sb->x2, sb->y2, 1);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
#include <X11/extensions/Xrender.h>
@@ -643,14 +671,16 @@ EndCompositeWin (XParms xp, Parms p)
}
}
-static void
+static int
CompositeArea(XParms xp, Parms p, int reps, Picture src, Picture dst)
{
int i, size;
XSegment *sa, *sb;
size = p->special;
- for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+ for (i = 0; i != reps; i++) {
+ sa = segsa + (i % nsegs);
+ sb = segsb + (i % nsegs);
XRenderComposite (xp->d, xp->func,
src, None, dst,
sa->x1, sa->y1, 0, 0,
@@ -664,18 +694,20 @@ CompositeArea(XParms xp, Parms p, int reps, Picture src, Picture dst)
XRenderComposite (xp->d, xp->func,
src, None, dst,
sb->x1, sb->y1, 0, 0, sb->x2, sb->y2, size, size);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoCompositeWinWin (XParms xp, Parms p, int reps)
{
- CompositeArea (xp, p, reps, winPict, winPict);
+ return CompositeArea (xp, p, reps, winPict, winPict);
}
-void
+int
DoCompositePixWin (XParms xp, Parms p, int reps)
{
- CompositeArea (xp, p, reps, pixPict, winPict);
+ return CompositeArea (xp, p, reps, pixPict, winPict);
}
diff --git a/do_complex.c b/do_complex.c
index 3eac738..bffcf1f 100644
--- a/do_complex.c
+++ b/do_complex.c
@@ -95,7 +95,7 @@ InitComplexPoly(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoComplexPoly(XParms xp, Parms p, int reps)
{
int i, j;
@@ -112,8 +112,10 @@ DoComplexPoly(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -168,7 +170,7 @@ InitGeneralPoly(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoGeneralPoly(XParms xp, Parms p, int reps)
{
int i, j;
@@ -189,6 +191,8 @@ DoGeneralPoly(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
diff --git a/do_dots.c b/do_dots.c
index 8279437..0aa89b7 100644
--- a/do_dots.c
+++ b/do_dots.c
@@ -42,7 +42,7 @@ InitDots(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoDots(XParms xp, Parms p, int reps)
{
int i;
@@ -53,8 +53,10 @@ DoDots(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_lines.c b/do_lines.c
index 88a1ebd..779e06c 100644
--- a/do_lines.c
+++ b/do_lines.c
@@ -272,7 +272,7 @@ InitWideDoubleDashedLines(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoLines(XParms xp, Parms p, int reps)
{
int i;
@@ -288,8 +288,10 @@ DoLines(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_movewin.c b/do_movewin.c
index ed96ae1..ffd92b8 100644
--- a/do_movewin.c
+++ b/do_movewin.c
@@ -62,7 +62,7 @@ InitMoveWindows(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoMoveWindows(XParms xp, Parms p, int reps)
{
int i, j;
@@ -78,8 +78,10 @@ DoMoveWindows(XParms xp, Parms p, int reps)
XMoveWindow(xp->d, children[j],
positions[j].x + x_offset, positions[j].y + y_offset);
}
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -89,7 +91,7 @@ EndMoveWindows(XParms xp, Parms p)
free(positions);
}
-void
+int
DoResizeWindows(XParms xp, Parms p, int reps)
{
int i, j, delta2;
@@ -102,8 +104,10 @@ DoResizeWindows(XParms xp, Parms p, int reps)
XResizeWindow(xp->d, children[j],
CHILDSIZE+delta2, CHILDSIZE-delta2);
}
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
int
@@ -126,7 +130,7 @@ InitCircWindows(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoCircWindows(XParms xp, Parms p, int reps)
{
int i, j;
@@ -135,8 +139,10 @@ DoCircWindows(XParms xp, Parms p, int reps)
{
for (j = 0; j != p->objects; j++)
XCirculateSubwindows (xp->d, xp->w, RaiseLowest);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -179,7 +185,7 @@ InitMoveTree(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoMoveTree(XParms xp, Parms p, int reps)
{
int i;
@@ -192,8 +198,10 @@ DoMoveTree(XParms xp, Parms p, int reps)
if (x_offset + xmax > WIDTH)
x_offset = 0;
XMoveWindow(xp->d, cover, x_offset, y_offset);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_rects.c b/do_rects.c
index f697cdb..958c127 100644
--- a/do_rects.c
+++ b/do_rects.c
@@ -83,7 +83,7 @@ InitRectangles(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoRectangles(XParms xp, Parms p, int reps)
{
int i;
@@ -94,11 +94,13 @@ DoRectangles(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoOutlineRectangles(XParms xp, Parms p, int reps)
{
int i;
@@ -109,8 +111,10 @@ DoOutlineRectangles(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_segs.c b/do_segs.c
index bc13fbd..805f25f 100644
--- a/do_segs.c
+++ b/do_segs.c
@@ -356,7 +356,7 @@ InitWideVertSegments(XParms xp, Parms p, int reps)
}
-void
+int
DoSegments(XParms xp, Parms p, int reps)
{
int i;
@@ -371,8 +371,10 @@ DoSegments(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_simple.c b/do_simple.c
index 0904b6f..2d1274a 100644
--- a/do_simple.c
+++ b/do_simple.c
@@ -31,19 +31,21 @@ SOFTWARE.
static Atom XA_PK_TEMP;
-void
+int
DoNoOp(XParms xp, Parms p, int reps)
{
int i;
for (i = 0; i != reps; i++) {
XNoOp(xp->d);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoGetAtom(XParms xp, Parms p, int reps)
{
char *atom;
@@ -52,11 +54,13 @@ DoGetAtom(XParms xp, Parms p, int reps)
for (i = 0; i != reps; i++) {
atom = XGetAtomName (xp->d, 1);
XFree(atom); /* fix XBUG 6480 */
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoQueryPointer(XParms xp, Parms p, int reps)
{
int i;
@@ -66,8 +70,10 @@ DoQueryPointer(XParms xp, Parms p, int reps)
for (i = 0; i != reps; i++) {
XQueryPointer (xp->d, xp->w, &w, &w, &x, &x, &x, &x, &m);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
int
@@ -86,7 +92,7 @@ InitGetProperty(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoGetProperty(XParms xp, Parms p, int reps)
{
int i;
@@ -101,7 +107,9 @@ DoGetProperty(XParms xp, Parms p, int reps)
xp->d, xp->w, XA_PK_TEMP, 0, 4,
False, AnyPropertyType, &actual_type, &actual_format,
&actual_length, &bytes_remaining, &prop);
- CheckAbort ();
XFree(prop);
+ if (CheckCancel()) return i;
}
+
+ return i;
}
diff --git a/do_text.c b/do_text.c
index 6b41201..f5eb2a0 100644
--- a/do_text.c
+++ b/do_text.c
@@ -217,7 +217,7 @@ InitText16(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoText(XParms xp, Parms p, int reps)
{
int i, line, startLine;
@@ -235,11 +235,13 @@ DoText(XParms xp, Parms p, int reps)
startLine = (startLine + 1) % totalLines;
}
line = (line + 1) % totalLines;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoText16(XParms xp, Parms p, int reps)
{
int i, line, startLine;
@@ -257,11 +259,13 @@ DoText16(XParms xp, Parms p, int reps)
startLine = (startLine + 1) % totalLines;
}
line = (line + 1) % totalLines;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoPolyText(XParms xp, Parms p, int reps)
{
int i, line, startLine;
@@ -279,11 +283,13 @@ DoPolyText(XParms xp, Parms p, int reps)
startLine = (startLine + 1) % totalLines;
}
line = (line + 1) % totalLines;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoPolyText16(XParms xp, Parms p, int reps)
{
int i, line, startLine;
@@ -301,11 +307,13 @@ DoPolyText16(XParms xp, Parms p, int reps)
startLine = (startLine + 1) % totalLines;
}
line = (line + 1) % totalLines;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoImageText(XParms xp, Parms p, int reps)
{
int i, line, startLine;
@@ -323,11 +331,13 @@ DoImageText(XParms xp, Parms p, int reps)
line = startLine;
}
line = (line + 1) % totalLines;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
-void
+int
DoImageText16(XParms xp, Parms p, int reps)
{
int i, line, startLine;
@@ -345,8 +355,10 @@ DoImageText16(XParms xp, Parms p, int reps)
line = startLine;
}
line = (line + 1) % totalLines;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -470,7 +482,7 @@ InitAAText(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoAAText(XParms xp, Parms p, int reps)
{
int i, line, startLine;
@@ -488,8 +500,10 @@ DoAAText(XParms xp, Parms p, int reps)
startLine = (startLine + 1) % totalLines;
}
line = (line + 1) % totalLines;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_traps.c b/do_traps.c
index 326b56e..6f9ef06 100644
--- a/do_traps.c
+++ b/do_traps.c
@@ -77,7 +77,7 @@ InitTrapezoids(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoTrapezoids(XParms xp, Parms p, int reps)
{
int i, j;
@@ -94,8 +94,10 @@ DoTrapezoids(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -229,7 +231,7 @@ InitFixedTraps(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoFixedTraps(XParms xp, Parms p, int reps)
{
int i;
@@ -250,8 +252,10 @@ DoFixedTraps(XParms xp, Parms p, int reps)
src = white;
else
src = black;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
@@ -363,7 +367,7 @@ InitFixedTrapezoids(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoFixedTrapezoids(XParms xp, Parms p, int reps)
{
int i;
@@ -381,8 +385,10 @@ DoFixedTrapezoids(XParms xp, Parms p, int reps)
src = white;
else
src = black;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_tris.c b/do_tris.c
index cf0200e..30520c8 100644
--- a/do_tris.c
+++ b/do_tris.c
@@ -131,7 +131,7 @@ InitTriangles(XParms xp, Parms p, int reps)
#ifndef POLYTRIANGLE_HACK
-void
+int
DoTriangles(XParms xp, Parms p, int reps)
{
int i, j;
@@ -148,8 +148,10 @@ DoTriangles(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
#else
@@ -206,7 +208,7 @@ XPolyTriangle(register Display *dpy,
SyncHandle();
}
-void
+int
DoTriangles(XParms xp, Parms p, int reps)
{
int i, j;
@@ -219,8 +221,10 @@ DoTriangles(XParms xp, Parms p, int reps)
pgc = xp->fggc;
else
pgc = xp->bggc;
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
#endif
diff --git a/do_valgc.c b/do_valgc.c
index 75f1a1a..8cab740 100644
--- a/do_valgc.c
+++ b/do_valgc.c
@@ -41,7 +41,7 @@ InitGC(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoChangeGC(XParms xp, Parms p, int reps)
{
int i;
@@ -63,8 +63,10 @@ DoChangeGC(XParms xp, Parms p, int reps)
gcv.foreground = xp->foreground;
XChangeGC(xp->d, xp->fggc, GCForeground , &gcv);
XDrawPoint(xp->d, win[1], xp->fggc, 5, 5);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/do_windows.c b/do_windows.c
index 024d76b..e8da795 100644
--- a/do_windows.c
+++ b/do_windows.c
@@ -83,7 +83,7 @@ CreateParents(XParms xp, Parms p, int reps)
} /* CreateParents */
-void
+int
MapParents(XParms xp, Parms p, int reps)
{
int i;
@@ -91,6 +91,7 @@ MapParents(XParms xp, Parms p, int reps)
for (i = 0; i != parentwindows; i++) {
XMapWindow(xp->d, parents[i]);
}
+ return parentwindows;
}
void
@@ -128,7 +129,7 @@ CreateChildGroup(XParms xp, Parms p, Window parent)
XMapSubwindows (xp->d, parent);
}
-void
+int
CreateChildren(XParms xp, Parms p, int reps)
{
int i;
@@ -136,6 +137,8 @@ CreateChildren(XParms xp, Parms p, int reps)
for (i = 0; i != parentwindows; i++) {
CreateChildGroup(xp, p, parents[i]);
} /* end i */
+
+ return parentwindows;
}
void
@@ -165,7 +168,7 @@ InitMap(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
UnmapParents(XParms xp, Parms p, int reps)
{
int i;
@@ -173,6 +176,8 @@ UnmapParents(XParms xp, Parms p, int reps)
for (i = 0; i != parentwindows; i++) {
XUnmapWindow(xp->d, parents[i]);
}
+
+ return parentwindows;
}
void
@@ -194,7 +199,7 @@ InitDestroy(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DestroyParents(XParms xp, Parms p, int reps)
{
int i;
@@ -202,6 +207,8 @@ DestroyParents(XParms xp, Parms p, int reps)
for (i = 0; i != parentwindows; i++) {
XDestroyWindow(xp->d, parents[i]);
}
+
+ return parentwindows;
}
@@ -259,15 +266,17 @@ InitPopups(XParms xp, Parms p, int reps)
return reps;
}
-void
+int
DoPopUps(XParms xp, Parms p, int reps)
{
int i;
for (i = 0; i != reps; i++) {
XMapWindow(xp->d, popup);
XUnmapWindow(xp->d, popup);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
void
diff --git a/x11perf.c b/x11perf.c
index 15eb04d..410967c 100644
--- a/x11perf.c
+++ b/x11perf.c
@@ -38,12 +38,18 @@ SOFTWARE.
#define Time_t time_t
#include <stdlib.h>
+#include <limits.h>
+#include <sys/time.h>
+#ifndef ITIMER_REAL
+#define NEED_CALIBRATE
+#endif
+
/* Only for working on ``fake'' servers, for hardware that doesn't exist */
static Bool drawToFakeServer = False;
static Bool falsePrecision = False;
static Pixmap tileToQuery = None;
static char *displayName;
-int abortTest;
+int abortTest = 0;
typedef struct _RopNames { char *name; int rop; } RopNameRec, *RopNamePtr;
@@ -228,6 +234,12 @@ PrintTime(void)
static void
InitTimes(void)
{
+#ifndef NEED_CALIBRATE
+ struct itimerval it = { {0, }, }, oit = { {0, }, };
+
+ it.it_value.tv_sec = seconds;
+ setitimer(ITIMER_REAL, &it, &oit);
+#endif
X_GETTIMEOFDAY(&start);
}
@@ -554,15 +566,17 @@ HardwareSync(XParms xp)
if (image) XDestroyImage(image);
}
-static void
+static int
DoHardwareSync(XParms xp, Parms p, int reps)
{
int i;
for (i = 0; i != reps; i++) {
HardwareSync(xp);
- CheckAbort ();
+ if (CheckCancel()) return i;
}
+
+ return i;
}
static Test syncTest = {
@@ -633,7 +647,7 @@ DestroyClipWindows(XParms xp, int clips)
static double
-DoTest(XParms xp, Test *test, int reps)
+DoTest(XParms xp, Test *test, int *reps)
{
double time;
unsigned int ret_width, ret_height;
@@ -643,7 +657,7 @@ DoTest(XParms xp, Test *test, int reps)
XForceScreenSaver(xp->d, ScreenSaverReset);
HardwareSync (xp);
InitTimes ();
- (*test->proc) (xp, &test->parms, reps);
+ *reps = (*test->proc) (xp, &test->parms, *reps);
HardwareSync(xp);
time = ElapsedTime(syncTime);
@@ -655,13 +669,12 @@ DoTest(XParms xp, Test *test, int reps)
return time;
}
-
static int
CalibrateTest(XParms xp, Test *test, int seconds, double *usecperobj)
{
-#define goal 2500000.0 /* Try to get up to 2.5 seconds */
-#define enough 2000000.0 /* But settle for 2.0 seconds */
-#define tick 10000.0 /* Assume clock not faster than .01 seconds */
+ double goal = 2500000.0; /* Try to get up to 2.5 seconds */
+ double enough = 2000000.0; /* But settle for 2.0 seconds */
+ double tick = 1000.0; /* Assume clock not faster than .001 seconds */
double usecs;
int reps, didreps; /* Reps desired, reps performed */
@@ -677,13 +690,17 @@ CalibrateTest(XParms xp, Test *test, int seconds, double *usecperobj)
if (fixedReps != 0) {
return fixedReps;
}
+
+ if (seconds * 1.0e6 < enough)
+ enough = seconds * 1.0e6;
+
reps = 1;
for (;;) {
XDestroySubwindows(xp->d, xp->w);
XClearWindow(xp->d, xp->w);
didreps = (*test->init) (xp, &test->parms, reps);
- CheckAbort ();
if (didreps == 0) {
+ printf("didreps = 0\n");
return 0;
}
if ( test->clips < clips )
@@ -698,7 +715,7 @@ CalibrateTest(XParms xp, Test *test, int seconds, double *usecperobj)
(*test->passCleanup) (xp, &test->parms);
(*test->cleanup) (xp, &test->parms);
DestroyClipWindows(xp, test->clips);
- CheckAbort ();
+ (void) CheckCancel ();
if (didreps != reps) {
/* The test can't do the number of reps as we asked for.
@@ -708,7 +725,9 @@ CalibrateTest(XParms xp, Test *test, int seconds, double *usecperobj)
return didreps;
}
/* Did we go long enough? */
- if (usecs >= enough) break;
+ if (usecs >= enough) {
+ break;
+ }
/* Don't let too short a clock make new reps wildly high */
if (usecs <= tick)reps = reps*10;
@@ -731,7 +750,7 @@ CalibrateTest(XParms xp, Test *test, int seconds, double *usecperobj)
}
reps = (reps + 1) * exponent;
return reps;
-} /* CalibrateTest */
+}
static void
CreatePerfGCs(XParms xp, int func, unsigned long pm)
@@ -838,7 +857,7 @@ static void
ProcessTest(XParms xp, Test *test, int func, unsigned long pm, char *label)
{
double time, totalTime;
- int reps;
+ int reps = INT_MAX;
int j;
xp->planemask = pm;
@@ -849,9 +868,14 @@ ProcessTest(XParms xp, Test *test, int func, unsigned long pm, char *label)
pm = ~0L;
}
CreatePerfGCs(xp, func, pm);
+#ifdef NEED_CALIBRATE
DisplayStatus(xp->d, "Calibrating", label, 0);
reps = CalibrateTest(xp, test, seconds, &time);
+#endif
if (reps != 0) {
+#ifndef NEED_CALIBRATE
+ reps = INT_MAX;
+#endif
srand(1); /* allow reproducible results */
XDestroySubwindows(xp->d, xp->w);
XClearWindow(xp->d, xp->w);
@@ -872,7 +896,7 @@ ProcessTest(XParms xp, Test *test, int func, unsigned long pm, char *label)
totalTime = 0.0;
for (j = 0; j != repeat; j++) {
DisplayStatus(xp->d, "Testing", label, j+1);
- time = DoTest(xp, test, reps);
+ time = DoTest(xp, test, &reps);
if (abortTest)
AbortTest ();
totalTime += time;
@@ -1274,6 +1298,9 @@ main(int argc, char *argv[])
#ifdef SIGHUP
(void) signal(SIGHUP, Cleanup);
#endif
+#ifndef NEED_CALIBRATE
+ (void) signal(SIGALRM, Cleanup);
+#endif
XSetScreenSaver(xparms.d, 8 * 3600, ssInterval, ssPreferBlanking,
ssAllowExposures);
diff --git a/x11perf.h b/x11perf.h
index 597b1f7..6501bce 100644
--- a/x11perf.h
+++ b/x11perf.h
@@ -37,6 +37,7 @@ SOFTWARE.
#include <X11/Xfuncs.h>
#endif
#include <stddef.h>
+#include <signal.h>
#include <X11/extensions/Xrender.h>
#define POLY 1000 /* # (small) items in poly calls */
@@ -103,7 +104,7 @@ typedef struct _XParms {
} XParmRec, *XParms;
typedef int (*InitProc)(XParms xp, Parms p, int reps);
-typedef void (*Proc)(XParms xp, Parms p, int reps);
+typedef int (*Proc)(XParms xp, Parms p, int reps);
typedef void (*CleanupProc)(XParms xp, Parms p);
typedef enum {
@@ -138,6 +139,19 @@ extern int abortTest;
extern void AbortTest (void);
#define CheckAbort() if (abortTest) AbortTest ()
+
+#include <stdio.h>
+static inline Bool CheckCancel(void)
+{
+ if (abortTest == SIGALRM) {
+ abortTest = 0;
+ return 1;
+ } else if (abortTest) {
+ AbortTest();
+ }
+ return 0;
+}
+
#define ForEachTest(x) for (x = 0; test[x].option != NULL; x++)
@@ -162,28 +176,28 @@ extern int InitDashedEllipses ( XParms xp, Parms p, int reps );
extern int InitWideDashedEllipses ( XParms xp, Parms p, int reps );
extern int InitDoubleDashedEllipses ( XParms xp, Parms p, int reps );
extern int InitWideDoubleDashedEllipses ( XParms xp, Parms p, int reps );
-extern void DoArcs ( XParms xp, Parms p, int reps );
-extern void DoFilledArcs ( XParms xp, Parms p, int reps );
+extern int DoArcs ( XParms xp, Parms p, int reps );
+extern int DoFilledArcs ( XParms xp, Parms p, int reps );
extern void EndArcs ( XParms xp, Parms p );
/* do_blt.c */
extern int InitScroll ( XParms xp, Parms p, int reps );
-extern void DoScroll ( XParms xp, Parms p, int reps );
+extern int DoScroll ( XParms xp, Parms p, int reps );
extern void MidScroll ( XParms xp, Parms p );
extern void EndScroll ( XParms xp, Parms p );
extern int InitCopyWin ( XParms xp, Parms p, int reps );
extern int InitCopyPix ( XParms xp, Parms p, int reps );
extern int InitGetImage ( XParms xp, Parms p, int reps );
extern int InitPutImage ( XParms xp, Parms p, int reps );
-extern void DoCopyWinWin ( XParms xp, Parms p, int reps );
-extern void DoCopyPixWin ( XParms xp, Parms p, int reps );
-extern void DoCopyWinPix ( XParms xp, Parms p, int reps );
-extern void DoCopyPixPix ( XParms xp, Parms p, int reps );
-extern void DoGetImage ( XParms xp, Parms p, int reps );
-extern void DoPutImage ( XParms xp, Parms p, int reps );
+extern int DoCopyWinWin ( XParms xp, Parms p, int reps );
+extern int DoCopyPixWin ( XParms xp, Parms p, int reps );
+extern int DoCopyWinPix ( XParms xp, Parms p, int reps );
+extern int DoCopyPixPix ( XParms xp, Parms p, int reps );
+extern int DoGetImage ( XParms xp, Parms p, int reps );
+extern int DoPutImage ( XParms xp, Parms p, int reps );
#ifdef MITSHM
extern int InitShmPutImage ( XParms xp, Parms p, int reps );
-extern void DoShmPutImage ( XParms xp, Parms p, int reps );
+extern int DoShmPutImage ( XParms xp, Parms p, int reps );
extern void EndShmPutImage ( XParms xp, Parms p );
#endif
extern void MidCopyPix ( XParms xp, Parms p );
@@ -191,7 +205,7 @@ extern void EndCopyWin ( XParms xp, Parms p );
extern void EndCopyPix ( XParms xp, Parms p );
extern void EndGetImage ( XParms xp, Parms p );
extern int InitCopyPlane ( XParms xp, Parms p, int reps );
-extern void DoCopyPlane ( XParms xp, Parms p, int reps );
+extern int DoCopyPlane ( XParms xp, Parms p, int reps );
int
InitCompositeWin(XParms xp, Parms p, int reps);
@@ -199,7 +213,7 @@ InitCompositeWin(XParms xp, Parms p, int reps);
void
EndCompositeWin (XParms xp, Parms p);
-void
+int
DoCompositeWinWin (XParms xp, Parms p, int reps);
int
@@ -208,19 +222,19 @@ InitCompositePix(XParms xp, Parms p, int reps);
void
EndCompositePix (XParms xp, Parms p);
-void
+int
DoCompositePixWin (XParms xp, Parms p, int reps);
/* do_complex.c */
extern int InitComplexPoly ( XParms xp, Parms p, int reps );
-extern void DoComplexPoly ( XParms xp, Parms p, int reps );
+extern int DoComplexPoly ( XParms xp, Parms p, int reps );
extern void EndComplexPoly ( XParms xp, Parms p );
extern int InitGeneralPoly ( XParms xp, Parms p, int reps );
-extern void DoGeneralPoly ( XParms xp, Parms p, int reps );
+extern int DoGeneralPoly ( XParms xp, Parms p, int reps );
/* do_dots.c */
extern int InitDots ( XParms xp, Parms p, int reps );
-extern void DoDots ( XParms xp, Parms p, int reps );
+extern int DoDots ( XParms xp, Parms p, int reps );
extern void EndDots ( XParms xp, Parms p );
/* do_lines.c */
@@ -230,25 +244,25 @@ extern int InitDashedLines ( XParms xp, Parms p, int reps );
extern int InitWideDashedLines ( XParms xp, Parms p, int reps );
extern int InitDoubleDashedLines ( XParms xp, Parms p, int reps );
extern int InitWideDoubleDashedLines ( XParms xp, Parms p, int reps );
-extern void DoLines ( XParms xp, Parms p, int reps );
+extern int DoLines ( XParms xp, Parms p, int reps );
extern void EndLines ( XParms xp, Parms p );
/* do_movewin.c */
extern int InitMoveWindows ( XParms xp, Parms p, int reps );
-extern void DoMoveWindows ( XParms xp, Parms p, int reps );
+extern int DoMoveWindows ( XParms xp, Parms p, int reps );
extern void EndMoveWindows ( XParms xp, Parms p );
-extern void DoResizeWindows ( XParms xp, Parms p, int reps );
+extern int DoResizeWindows ( XParms xp, Parms p, int reps );
extern int InitCircWindows ( XParms xp, Parms p, int reps );
-extern void DoCircWindows ( XParms xp, Parms p, int reps );
+extern int DoCircWindows ( XParms xp, Parms p, int reps );
extern void EndCircWindows ( XParms xp, Parms p );
extern int InitMoveTree ( XParms xp, Parms p, int reps );
-extern void DoMoveTree ( XParms xp, Parms p, int reps );
+extern int DoMoveTree ( XParms xp, Parms p, int reps );
extern void EndMoveTree ( XParms xp, Parms p );
/* do_rects.c */
extern int InitRectangles ( XParms xp, Parms p, int reps );
-extern void DoRectangles ( XParms xp, Parms p, int reps );
-extern void DoOutlineRectangles ( XParms xp, Parms p, int reps );
+extern int DoRectangles ( XParms xp, Parms p, int reps );
+extern int DoOutlineRectangles ( XParms xp, Parms p, int reps );
extern void EndRectangles ( XParms xp, Parms p );
/* do_segs.c */
@@ -259,73 +273,73 @@ extern int InitHorizSegments ( XParms xp, Parms p, int reps );
extern int InitWideHorizSegments ( XParms xp, Parms p, int reps );
extern int InitVertSegments ( XParms xp, Parms p, int reps );
extern int InitWideVertSegments ( XParms xp, Parms p, int reps );
-extern void DoSegments ( XParms xp, Parms p, int reps );
+extern int DoSegments ( XParms xp, Parms p, int reps );
extern void EndSegments ( XParms xp, Parms p );
/* do_simple.c */
-extern void DoNoOp ( XParms xp, Parms p, int reps );
-extern void DoGetAtom ( XParms xp, Parms p, int reps );
-extern void DoQueryPointer ( XParms xp, Parms p, int reps );
+extern int DoNoOp ( XParms xp, Parms p, int reps );
+extern int DoGetAtom ( XParms xp, Parms p, int reps );
+extern int DoQueryPointer ( XParms xp, Parms p, int reps );
extern int InitGetProperty ( XParms xp, Parms p, int reps );
-extern void DoGetProperty ( XParms xp, Parms p, int reps );
+extern int DoGetProperty ( XParms xp, Parms p, int reps );
/* do_text.c */
extern int InitText ( XParms xp, Parms p, int reps );
extern int InitText16 ( XParms xp, Parms p, int reps );
-extern void DoText ( XParms xp, Parms p, int reps );
-extern void DoText16 ( XParms xp, Parms p, int reps );
-extern void DoPolyText ( XParms xp, Parms p, int reps );
-extern void DoPolyText16 ( XParms xp, Parms p, int reps );
-extern void DoImageText ( XParms xp, Parms p, int reps );
-extern void DoImageText16 ( XParms xp, Parms p, int reps );
+extern int DoText ( XParms xp, Parms p, int reps );
+extern int DoText16 ( XParms xp, Parms p, int reps );
+extern int DoPolyText ( XParms xp, Parms p, int reps );
+extern int DoPolyText16 ( XParms xp, Parms p, int reps );
+extern int DoImageText ( XParms xp, Parms p, int reps );
+extern int DoImageText16 ( XParms xp, Parms p, int reps );
extern void ClearTextWin ( XParms xp, Parms p );
extern void EndText ( XParms xp, Parms p );
extern void EndText16 ( XParms xp, Parms p );
#ifdef XFT
extern int InitAAText (XParms xp, Parms p, int reps );
-extern void DoAAText (XParms xp, Parms p, int reps );
+extern int DoAAText (XParms xp, Parms p, int reps );
extern void EndAAText ( XParms xp, Parms p );
#endif
/* do_traps.c */
extern int InitTrapezoids ( XParms xp, Parms p, int reps );
-extern void DoTrapezoids ( XParms xp, Parms p, int reps );
+extern int DoTrapezoids ( XParms xp, Parms p, int reps );
extern void EndTrapezoids ( XParms xp, Parms p );
#ifdef XRENDER
extern int InitFixedTraps ( XParms xp, Parms p, int reps );
-extern void DoFixedTraps ( XParms xp, Parms p, int reps );
+extern int DoFixedTraps ( XParms xp, Parms p, int reps );
extern void EndFixedTraps ( XParms xp, Parms p );
extern int InitFixedTrapezoids ( XParms xp, Parms p, int reps );
-extern void DoFixedTrapezoids ( XParms xp, Parms p, int reps );
+extern int DoFixedTrapezoids ( XParms xp, Parms p, int reps );
extern void EndFixedTrapezoids ( XParms xp, Parms p );
#endif
/* do_tris.c */
extern int InitTriangles ( XParms xp, Parms p, int reps );
-extern void DoTriangles ( XParms xp, Parms p, int reps );
+extern int DoTriangles ( XParms xp, Parms p, int reps );
extern void EndTriangles ( XParms xp, Parms p );
/* do_valgc.c */
extern int InitGC ( XParms xp, Parms p, int reps );
-extern void DoChangeGC ( XParms xp, Parms p, int reps );
+extern int DoChangeGC ( XParms xp, Parms p, int reps );
extern void EndGC ( XParms xp, Parms p );
/* do_windows.c */
extern int CreateParents ( XParms xp, Parms p, int reps );
-extern void MapParents ( XParms xp, Parms p, int reps );
+extern int MapParents ( XParms xp, Parms p, int reps );
extern void MapParentsCleanup ( XParms xp, Parms p );
extern int InitCreate ( XParms xp, Parms p, int reps );
-extern void CreateChildren ( XParms xp, Parms p, int reps );
+extern int CreateChildren ( XParms xp, Parms p, int reps );
extern void DestroyChildren ( XParms xp, Parms p );
extern void EndCreate ( XParms xp, Parms p );
extern int InitMap ( XParms xp, Parms p, int reps );
-extern void UnmapParents ( XParms xp, Parms p, int reps );
+extern int UnmapParents ( XParms xp, Parms p, int reps );
extern void UnmapParentsCleanup ( XParms xp, Parms p);
extern int InitDestroy ( XParms xp, Parms p, int reps );
-extern void DestroyParents ( XParms xp, Parms p, int reps );
+extern int DestroyParents ( XParms xp, Parms p, int reps );
extern void RenewParents ( XParms xp, Parms p );
extern int InitPopups ( XParms xp, Parms p, int reps );
-extern void DoPopUps ( XParms xp, Parms p, int reps );
+extern int DoPopUps ( XParms xp, Parms p, int reps );
extern void EndPopups ( XParms xp, Parms p );
--
1.6.5.2
More information about the xorg-devel
mailing list