home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
x
/
x11p-13.zip
/
RCS
/
x11perf.c,v
< prev
next >
Wrap
Text File
|
1990-03-15
|
51KB
|
2,440 lines
head 2.25;
access ;
symbols pre-merge:2.0;
locks joel:2.25; strict;
comment @ * @;
2.25
date 89.12.28.12.47.01; author joel; state Exp;
branches ;
next 2.24;
2.24
date 89.12.27.19.05.49; author joel; state Exp;
branches ;
next 2.23;
2.23
date 89.12.14.10.08.39; author joel; state Exp;
branches ;
next 2.22;
2.22
date 89.12.14.09.48.33; author joel; state Exp;
branches ;
next 2.21;
2.21
date 89.12.14.09.34.11; author joel; state Exp;
branches ;
next 2.20;
2.20
date 89.12.12.17.32.04; author joel; state Exp;
branches ;
next 2.19;
2.19
date 89.12.07.16.37.42; author joel; state Exp;
branches ;
next 2.18;
2.18
date 89.11.21.08.55.55; author joel; state Exp;
branches ;
next 2.17;
2.17
date 89.11.02.10.48.10; author joel; state Exp;
branches ;
next 2.16;
2.16
date 89.10.25.14.57.24; author joel; state Exp;
branches ;
next 2.15;
2.15
date 89.10.24.09.48.33; author joel; state Exp;
branches ;
next 2.14;
2.14
date 89.10.06.15.15.53; author joel; state Exp;
branches ;
next 2.13;
2.13
date 89.09.28.15.25.28; author joel; state Exp;
branches ;
next 2.12;
2.12
date 89.06.23.14.14.16; author joel; state Exp;
branches ;
next 2.11;
2.11
date 89.05.17.11.06.43; author joel; state Exp;
branches ;
next 2.10;
2.10
date 89.05.16.21.00.10; author joel; state Exp;
branches ;
next 2.9;
2.9
date 89.05.16.12.07.19; author joel; state Exp;
branches ;
next 2.8;
2.8
date 89.05.16.11.44.41; author joel; state Exp;
branches ;
next 2.7;
2.7
date 89.05.12.12.21.34; author joel; state Exp;
branches ;
next 2.6;
2.6
date 89.05.11.17.41.55; author joel; state Exp;
branches ;
next 2.5;
2.5
date 89.05.11.16.45.23; author joel; state Exp;
branches ;
next 2.4;
2.4
date 89.05.08.18.38.02; author joel; state Exp;
branches ;
next 2.3;
2.3
date 89.05.04.13.44.16; author joel; state Exp;
branches ;
next 2.2;
2.2
date 89.05.03.14.18.29; author joel; state Exp;
branches ;
next 2.1;
2.1
date 89.04.18.14.15.47; author joel; state Exp;
branches ;
next 2.0;
2.0
date 89.02.21.14.37.02; author erik; state Exp;
branches ;
next 1.6;
1.6
date 89.02.21.14.37.02; author joel; state Exp;
branches ;
next 1.5;
1.5
date 89.01.31.17.08.21; author joel; state Exp;
branches ;
next 1.4;
1.4
date 88.11.26.16.21.59; author joel; state Exp;
branches ;
next 1.3;
1.3
date 88.10.13.14.01.41; author todd; state Exp;
branches ;
next 1.2;
1.2
date 88.07.27.09.56.40; author joel; state Exp;
branches ;
next 1.1;
1.1
date 88.06.20.21.41.02; author joel; state Exp;
branches ;
next ;
desc
@@
2.25
log
@Make -labels option pay attention to which tests are specified
@
text
@/*****************************************************************************
Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#ifndef VMS
#include <X11/Xatom.h>
#include <X11/Xos.h>
#else
#include <decw$include/Xatom.h>
#endif
#include "x11perf.h"
/* Only for working on ``fake'' servers, for hardware that doesn't exist */
static Bool drawToFakeServer = False;
static Pixmap tileToQuery = None;
static Bool labels = False;
static Bool xorMode = False;
static Bool bothModes = False;
static int repeat = 5;
static int seconds = 5;
static Window status; /* Status window and GC */
static GC tgc;
static double syncTime = 0.0;
static int saveargc;
static char **saveargv;
static char *foreground = NULL;
static char *background = NULL;
static int fixedReps = 0;
static Bool *doit;
static XRectangle ws[] = { /* Clip rectangles */
{195, 195, 120, 120},
{ 45, 145, 120, 120},
{345, 245, 120, 120}
};
#define MAXCLIP (sizeof(ws) / sizeof(ws[0]))
static Window clipWindows[MAXCLIP];
/************************************************
* time related stuff *
************************************************/
#ifdef VMS
typedef struct _vms_time {
unsigned long low;
unsigned long high;
}vms_time;
struct timeval {
long tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
};
struct timezone {
int tz_minuteswest; /* of Greenwich */
int tz_dsttime; /* type of dst correction to apply */
};
static int firsttime = True;
static vms_time basetime;
int gettimeofday(tp, tzp)
struct timeval *tp;
struct timezone *tzp;
{
vms_time current_time, resultant;
unsigned long mumble, foo;
int status;
if (firsttime) {
sys$gettim(&basetime);
firsttime = False;
}
sys$gettim(¤t_time);
resultant.high = current_time.high - basetime.high;
resultant.low = current_time.low - basetime.low;
if (current_time.low < basetime.low) {
resultant.high -= 1;
}
status = lib$ediv( &(10000000), &resultant, &tp->tv_sec, &tp->tv_usec);
tp->tv_usec /= 10;
return 0;
}
#endif
static struct timeval start;
void PrintTime()
{
time_t t;
t = time((long *)NULL);
printf("%s\n", ctime(&t));
}
void InitTimes ()
{
struct timezone foo;
gettimeofday(&start, &foo);
}
double ElapsedTime(correction)
double correction;
{
struct timeval stop;
struct timezone foo;
gettimeofday(&stop, &foo);
if (stop.tv_usec < start.tv_usec) {
stop.tv_usec += 1000000;
stop.tv_sec -= 1;
}
return (double)(stop.tv_usec - start.tv_usec) +
(1000000.0 * (double)(stop.tv_sec - start.tv_sec)) - correction;
}
double RoundTo3Digits(d)
double d;
{
/* It's kind of silly to print out things like ``193658.4/sec'' so just
junk all but 3 most significant digits. */
double exponent;
exponent = 1.0;
if (d >= 1000.0) {
do {
exponent *= 10.0;
} while (d/exponent >= 1000.0);
d = (double)((int) (d/exponent + 0.5));
d *= exponent;
} else {
while (d*exponent < 100.0) {
exponent *= 10.0;
}
d = (double)((int) (d*exponent + 0.5));
d /= exponent;
}
return d;
}
void ReportTimes(usecs, n, str, average)
double usecs;
int n;
char *str;
{
double msecsperobj, objspersec;
msecsperobj = usecs / (1000.0 * (double)n);
objspersec = (double) n * 1000000.0 / usecs;
/* Round obj/sec to 3 significant digits. Leave msec untouched, to allow
averaging results from several repetitions. */
objspersec = RoundTo3Digits(objspersec);
if (average) {
printf("%6d trep @@ %7.4f msec (%6.1f/sec): %s\n",
n, msecsperobj, objspersec, str);
} else {
printf("%6d reps @@ %7.4f msec (%6.1f/sec): %s\n",
n, msecsperobj, objspersec, str);
}
}
/************************************************
* Generic X stuff *
************************************************/
static char *program_name;
void usage();
/*
* Get_Display_Name (argc, argv) Look for -display, -d, or host:dpy (obselete)
* If found, remove it from command line. Don't go past a lone -.
*/
char *Get_Display_Name(pargc, argv)
int *pargc; /* MODIFIED */
char **argv; /* MODIFIED */
{
int argc = *pargc;
char **pargv = argv+1;
char *displayname = NULL;
int i;
for (i = 1; i != argc; i++) {
char *arg = argv[i];
if (!strcmp (arg, "-display") || !strcmp (arg, "-d")) {
if (++i >= argc) usage ();
displayname = argv[i];
*pargc -= 2;
continue;
}
if (!strcmp(arg,"-")) {
while (i<argc) *pargv++ = argv[i++];
break;
}
*pargv++ = arg;
}
*pargv = NULL;
return (displayname);
}
/*
* Open_Display: Routine to open a display with correct error handling.
*/
Display *Open_Display(display_name)
char *display_name;
{
Display *d;
d = XOpenDisplay(display_name);
if (d == NULL) {
fprintf (stderr, "%s: unable to open display '%s'\n",
program_name, XDisplayName (display_name));
usage ();
/* doesn't return */
}
return(d);
}
/************************************************
* Performance stuff *
************************************************/
void usage()
{
char **cpp;
int i = 0;
static char *help_message[] = {
"where options include:",
" -display host:dpy the X server to contact",
" -sync do the tests in synchronous mode",
" -repeat <n> do tests <n> times (default = 5)",
" -time <s> do tests for <s> seconds each (default = 5)",
/*" -draw draw after each test -- pmax only",*/
" -all do all tests",
" -range <test1>[,<test2>] like all, but do <test1> to <test2>",
" -labels generate test labels for use by x11perffill",
" -fg the foreground color to use",
" -bg the background color to use",
" -xor use GXxor mode to draw",
" -both use both GXcopy and GXxor mode to draw",
" -reps <n> fix the rep count (default = auto scale)",
" -subs <s0 s1 ...> a list of the number of sub-windows to use",
NULL};
fflush(stdout);
fprintf(stderr, "usage: %s [-options ...]\n", program_name);
for (cpp = help_message; *cpp; cpp++) {
fprintf(stderr, "%s\n", *cpp);
}
while (test[i].option != NULL) {
fprintf(stderr, " %-28s %s\n",
test[i].option, test[i].label);
i++;
}
fprintf(stderr, "\n");
/* Print out original command line as the above usage message is so long */
for (i = 0; i != saveargc; i++) {
fprintf(stderr, "%s ", saveargv[i]);
}
fprintf(stderr, "\n\n");
exit (1);
}
void NullProc(xp, p)
XParms xp;
Parms p;
{
}
Bool NullInitProc(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
return reps;
}
void HardwareSync(xp)
XParms xp;
{
/*
* Some graphics hardware allows the server to claim it is done,
* while in reality the hardware is busily working away. So fetch
* a pixel from the window that was drawn to, which should be
* enough to make the server wait for the graphics hardware.
*/
XImage *image;
image = XGetImage(xp->d, xp->w, WIDTH-1, HEIGHT-1, 1, 1, ~0, ZPixmap);
XDestroyImage(image);
}
void DoHardwareSync(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != reps; i++) {
HardwareSync(xp);
}
}
static Test syncTest = {
"syncTime", "Internal test for finding how long HardwareSync takes",
NullInitProc, DoHardwareSync, NullProc, NullProc, NONXOR, 0,
{1}
};
static Window CreatePerfWindow(xp, x, y, width, height)
XParms xp;
int width, height, x, y;
{
XSetWindowAttributes xswa;
Window w;
Screen *s;
int su;
/*
s = DefaultScreenOfDisplay(xp->d);
su = XDoesBackingStore(s);
printf("Backing store of screen returns %d\n", su);
su = XDoesSaveUnders(s);
printf("Save unders of screen returns %d\n", su);
su = XPlanesOfScreen(s);
printf("Planes of screen returns %d\n", su);
*/
xswa.override_redirect = True;
xswa.backing_store = False;
xswa.save_under = False;
w = XCreateSimpleWindow (xp->d, DefaultRootWindow (xp->d),
x, y, width, height, 1, xp->foreground, xp->background);
XChangeWindowAttributes (xp->d, w,
CWOverrideRedirect | CWSaveUnder | CWBackingStore, &xswa);
XMapWindow (xp->d, w);
return w;
}
void CreateClipWindows(xp, clips)
XParms xp;
int clips;
{
int j;
XWindowAttributes xwa;
(void) XGetWindowAttributes(xp->d, xp->w, &xwa);
if (clips > MAXCLIP) clips = MAXCLIP;
for (j = 0; j != clips; j++) {
clipWindows[j] = CreatePerfWindow(xp,
xwa.x + ws[j].x, xwa.y + ws[j].y, ws[j].width, ws[j].height);
}
} /* CreateClipWindows */
void DestroyClipWindows(xp, clips)
XParms xp;
int clips;
{
int j;
if (clips > MAXCLIP) clips = MAXCLIP;
for (j = 0; j != clips; j++) {
XDestroyWindow(xp->d, clipWindows[j]);
}
} /* DestroyClipWindows */
double DoTest(xp, test, reps)
XParms xp;
Test *test;
int reps;
{
double time;
int ret_width, ret_height;
HardwareSync (xp);
InitTimes ();
(*test->proc) (xp, &test->parms, reps);
HardwareSync(xp);
time = ElapsedTime(syncTime);
if (drawToFakeServer)
XQueryBestSize(xp->d, TileShape, tileToQuery,
32, 32, &ret_width, &ret_height);
(*test->passCleanup) (xp, &test->parms);
return time;
}
int CalibrateTest(xp, test, seconds, usecperobj)
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 usecs;
int reps, didreps; /* Reps desired, reps performed */
int exponent;
/* Attempt to get an idea how long each rep lasts by getting enough
reps to last more tan enough. Then scale that up to the number of
seconds desired.
If init call to test ever fails, return False and test will be skipped.
*/
if (fixedReps != 0) {
return fixedReps;
}
reps = 1;
for (;;) {
XDestroySubwindows(xp->d, xp->w);
XClearWindow(xp->d, xp->w);
didreps = (*test->init) (xp, &test->parms, reps);
if (didreps == 0) {
return 0;
}
/* Create clip windows if requested */
CreateClipWindows(xp, test->clips);
HardwareSync(xp);
InitTimes();
(*test->proc) (xp, &test->parms, reps);
HardwareSync(xp);
usecs = ElapsedTime(syncTime);
(*test->passCleanup) (xp, &test->parms);
(*test->cleanup) (xp, &test->parms);
DestroyClipWindows(xp, test->clips);
if (didreps != reps) {
/* The test can't do the number of reps as we asked for.
Give up */
*usecperobj =
usecs / (double)(didreps * test->parms.objects);
return didreps;
}
/* Did we go long enough? */
if (usecs >= enough) break;
/* Don't let too short a clock make new reps wildly high */
if (usecs < tick) usecs = tick;
/* Try to get up to goal seconds. */
reps = (int) (goal * (double)reps / usecs) + 1;
}
*usecperobj = usecs / (double) (reps * test->parms.objects);
reps = (int) ((double)seconds * 1000000.0 * (double)reps / usecs) + 1;
/* Now round reps up to 1 digit accuracy, so we don't get stupid-looking
numbers of repetitions. */
reps--;
exponent = 1;
while (reps > 9) {
reps /= 10;
exponent *= 10;
}
reps = (reps + 1) * exponent;
return reps;
} /* CalibrateTest */
void CreatePerfGCs(xp, func)
XParms xp;
int func;
{
XGCValues gcv;
gcv.graphics_exposures = False;
if (func == GXxor) {
gcv.function = GXxor;
gcv.foreground = xp->background ^ xp->foreground;
gcv.background = xp->background;
xp->fggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures | GCFunction,
&gcv);
xp->bggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures | GCFunction,
&gcv);
} else {
gcv.foreground = xp->foreground;
gcv.background = xp->background;
xp->fggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures, &gcv);
gcv.foreground = xp->background;
gcv.background = xp->foreground;
xp->bggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures, &gcv);
}
}
void DestroyPerfGCs(xp)
XParms(xp);
{
XFreeGC(xp->d, xp->fggc);
XFreeGC(xp->d, xp->bggc);
}
int AllocateColor(display, name, pixel)
Display *display;
char *name;
int pixel;
{
XColor color;
Colormap cmap;
if (name != NULL) {
cmap = XDefaultColormap(display, DefaultScreen(display));
/* Try to parse color name */
if (XParseColor(display, cmap, name, &color)) {
if (XAllocColor(display, cmap, &color)) {
pixel = color.pixel;
} else {
(void) fprintf(stderr,
"Can't allocate colormap entry for color %s\n", name);
}
} else {
(void) fprintf(stderr, "Can't parse color name %s\n", name);
}
}
return pixel;
} /* AllocateColor */
void DisplayStatus(d, message, test)
Display *d;
char *message;
char *test;
{
char s[500];
XClearWindow(d, status);
sprintf(s, "%s %s", message, test);
/* We should really look at the height, descent of the font, etc. but
who cares. This works. */
XDrawString(d, status, tgc, 10, 13, s, strlen(s));
}
void ProcessTest(xp, test, func, label)
XParms xp;
Test *test;
int func;
char *label;
{
double time, totalTime;
int reps;
int j;
CreatePerfGCs(xp, func);
DisplayStatus(xp->d, "Calibrating", label);
reps = CalibrateTest(xp, test, seconds, &time);
if (reps != 0) {
DisplayStatus(xp->d, "Testing", label);
XDestroySubwindows(xp->d, xp->w);
XClearWindow(xp->d, xp->w);
(void)(*test->init) (xp, &test->parms, reps);
/* Create clip windows if requested */
CreateClipWindows(xp, test->clips);
totalTime = 0.0;
for (j = 0; j != repeat; j++) {
time = DoTest(xp, test, reps);
totalTime += time;
ReportTimes (time, reps * test->parms.objects,
label, False);
}
if (repeat > 1) {
ReportTimes(totalTime,
repeat * reps * test->parms.objects,
label, True);
}
(*test->cleanup) (xp, &test->parms);
DestroyClipWindows(xp, test->clips);
} else {
/* Test failed to initialize properly */
}
printf ("\n");
fflush(stdout);
DestroyPerfGCs(xp);
} /* ProcessTest */
main(argc, argv)
int argc;
char **argv;
{
int i, j;
int numTests; /* Even though the linker knows, we don't. */
char hostname[100];
char *displayName;
XParmRec xparms;
Bool foundOne = False;
Bool synchronous = False;
XGCValues tgcv;
int screen;
/* ScreenSaver state */
int ssTimeout, ssInterval, ssPreferBlanking, ssAllowExposures;
/* Save away argv, argc, for usage to print out */
saveargc = argc;
saveargv = (char **) malloc(argc * sizeof(char *));
for (i = 0; i != argc; i++) {
saveargv[i] = argv[i];
}
xparms.pack = False;
/* Count number of tests */
ForEachTest(numTests);
doit = (Bool *)calloc(numTests, sizeof(Bool));
/* Parse arguments */
program_name = argv[0];
displayName = Get_Display_Name (&argc, argv);
for (i = 1; i != argc; i++) {
if (strcmp (argv[i], "-all") == 0) {
ForEachTest (j)
doit[j] = True;
foundOne = True;
} else if (strcmp (argv[i], "-labels") == 0) {
labels = True;
} else if (strcmp(argv[i], "-range") == 0) {
char *cp1;
char *cp2;
if (argc <= ++i)
usage();
cp1 = argv[i];
if (*cp1 == '-')
*cp1++;
for (cp2 = cp1; *cp2 != '\0' && *cp2 != ','; cp2++) {};
if (*cp2 == ',') {
*cp2++ = '\0';
if (*cp2 == '-')
*cp2++;
} else {
cp2 = "-";
}
ForEachTest (j) {
if (strcmp (cp1, (test[j].option) + 1) == 0) {
int k = j;
do {
doit[k] = True;
} while (strcmp(cp2, (test[k].option + 1)) != 0 &&
test[++k].option != NULL);
if (*cp2 != '-' && test[k].option == NULL)
usage();
break;
}
}
if (test[j].option == NULL)
usage();
foundOne = True;
} else if (strcmp (argv[i], "-sync") == 0) {
synchronous = True;
} else if (strcmp(argv[i], "-pack") == 0) {
xparms.pack = True;
} else if (strcmp (argv[i], "-draw") == 0) {
drawToFakeServer = True;
} else if (strcmp (argv[i], "-repeat") == 0) {
if (argc <= i)
usage ();
repeat = atoi (argv[++i]);
if (repeat <= 0)
usage ();
} else if (strcmp (argv[i], "-time") == 0) {
if (argc <= i)
usage ();
seconds = atoi (argv[++i]);
if (seconds <= 0)
usage ();
} else if (strcmp(argv[i], "-fg") == 0) {
if (argc <= i)
usage ();
i++;
foreground = argv[i];
} else if (strcmp(argv[i], "-bg") == 0) {
if (argc <= i)
usage ();
i++;
background = argv[i];
} else if (strcmp(argv[i], "-xor") == 0) {
xorMode = True;
} else if (strcmp(argv[i], "-both") == 0) {
bothModes = True;
} else if (strcmp(argv[i], "-reps") == 0) {
if (argc <= i)
usage ();
fixedReps = atoi (argv[++i]);
if (fixedReps <= 0)
usage ();
} else if (strcmp(argv[i], "-subs") == 0) {
int j = 0;
if (argc <= i)
usage ();
i++;
while (i < argc && isdigit (argv[i][0]))
{
if (subs[j] != 0) {
subs[j] = atoi (argv[i++]);
j++;
}
i++;
}
--i;
} else {
ForEachTest (j) {
if (strcmp (argv[i], test[j].option) == 0) {
doit[j] = True;
goto LegalOption;
}
}
usage ();
LegalOption:
foundOne = True;
}
}
if (labels) {
/* Just print out list of tests for use with .sh programs that
assemble data from different x11perf runs into a nice format */
ForEachTest (i) {
int child;
if (doit[i]) {
switch (test[i].testType) {
case NONXOR:
printf ("%s\n", test[i].label);
break;
case XOR:
if (!xorMode || bothModes) {
printf ("%s\n", test[i].label);
}
if (xorMode || bothModes) {
printf("(XOR) %s\n", test[i].label);
}
break;
case WINDOW:
for (child = 0; subs[child] != 0; child++) {
printf ("%s (%d kids)\n",
test[i].label, subs[child]);
}
break;
} /* switch */
}
}
exit(0);
}
if (!foundOne)
usage ();
xparms.d = Open_Display (displayName);
printf("x11perf - X11 performance program, version 1.2\n");
#ifndef VMS
gethostname (hostname, 100);
printf ("%s server on %s\nfrom %s\n",
ServerVendor (xparms.d), DisplayString (xparms.d), hostname);
#else
printf ("%s server on %s\n",
ServerVendor (xparms.d), DisplayString (xparms.d));
#endif
screen = DefaultScreen (xparms.d);
PrintTime ();
/* Force screen out of screen-saver mode, grab current data, and set
time to blank to 8 hours. This finesses various problems if you
try to turn it off completely. As long as the tests run to
completion, the old screen-saver values are restored. */
XForceScreenSaver(xparms.d, ScreenSaverReset);
XGetScreenSaver(xparms.d, &ssTimeout, &ssInterval, &ssPreferBlanking,
&ssAllowExposures);
XSetScreenSaver(xparms.d, 8 * 3600, ssInterval, ssPreferBlanking,
ssAllowExposures);
if (drawToFakeServer) {
tileToQuery =
XCreatePixmap(xparms.d, DefaultRootWindow (xparms.d), 32, 32, 1);
}
xparms.foreground =
AllocateColor(xparms.d, foreground, BlackPixel(xparms.d, screen));
xparms.background =
AllocateColor(xparms.d, background, WhitePixel(xparms.d, screen));
xparms.w = CreatePerfWindow(&xparms, 2, 2, WIDTH, HEIGHT);
status = CreatePerfWindow(&xparms, 2, HEIGHT+5, WIDTH, 20);
tgcv.foreground = BlackPixel(xparms.d, screen);
tgcv.background = WhitePixel(xparms.d, screen);
tgc = XCreateGC(xparms.d, status, GCForeground | GCBackground, &tgcv);
if (synchronous)
XSynchronize (xparms.d, True);
/* Get mouse pointer out of the way of the performance window. On
software cursor machines it will slow graphics performance. On
all current MIT-derived servers it will slow window
creation/configuration performance. */
XWarpPointer(xparms.d, None, status, 0, 0, 0, 0, WIDTH, 20);
/* Figure out how long to call HardwareSync, so we can adjust for that
in our total elapsed time */
(void) CalibrateTest(&xparms, &syncTest, 1, &syncTime);
printf("Sync time adjustment is %6.4f msecs.\n\n", syncTime/1000);
ForEachTest (i) {
int child;
char label[200];
if (doit[i]) {
switch (test[i].testType) {
case NONXOR:
/* Simplest...just run it once */
strcpy (label, test[i].label);
ProcessTest(&xparms, &test[i], GXcopy, label);
break;
case XOR:
/* Run it once or twice */
if (!xorMode || bothModes) {
/* Copy mode */
strcpy (label, test[i].label);
ProcessTest(&xparms, &test[i], GXcopy, label);
}
if (xorMode || bothModes) {
/* Xor mode */
sprintf(label, "(XOR) %s", test[i].label);
ProcessTest(&xparms, &test[i], GXxor, label);
}
break;
case WINDOW:
/* Loop through number of children array */
for (child = 0; subs[child] != 0; child++) {
test[i].parms.objects = subs[child];
sprintf(label, "%s (%d kids)",
test[i].label, test[i].parms.objects);
ProcessTest(&xparms, &test[i], GXcopy, label);
}
break;
} /* switch */
} /* if doit */
} /* ForEachTest */
XDestroyWindow(xparms.d, xparms.w);
/* Restore ScreenSaver to original state. */
XSetScreenSaver(xparms.d, ssTimeout, ssInterval, ssPreferBlanking,
ssAllowExposures);
}
@
2.24
log
@Don't use index function; it doesn't exist on VMS
@
text
@d280 1
a280 1
" -labels generate test labels for use by fillblanks.sh",
d781 3
a783 7
switch (test[i].testType) {
case NONXOR:
printf ("%s\n", test[i].label);
break;
case XOR:
if (!xorMode || bothModes) {
d785 19
a803 12
}
if (xorMode || bothModes) {
printf("(XOR) %s\n", test[i].label);
}
break;
case WINDOW:
for (child = 0; subs[child] != 0; child++) {
printf ("%s (%d kids)\n", test[i].label, subs[child]);
}
break;
} /* switch */
@
2.23
log
@Fix a couple places where'd I'd missed in the reps as explicit parameter change
@
text
@d688 2
a689 1
if ((cp2 = index(cp1, ',')) != NULL) {
@
2.22
log
@Added -pack option (see do_rects.c)
@
text
@d315 1
a315 1
Bool NullInitProc(xp, p)
d318 1
d320 1
a320 1
return True;
d354 1
a354 1
{5000, 1}
@
2.21
log
@Changed positions of clip rectangles to match seg100 better
@
text
@d662 2
d709 1
a709 1
} else if (strcmp (argv[i], "-sync") == 0) {
d711 2
@
2.20
log
@Changed -start option to -range option
Changed to version 1.2
@
text
@d61 3
a63 3
{240, 240, 120, 120},
{ 40, 190, 120, 120},
{440, 290, 120, 120}
@
2.19
log
@Changed interface to p->reps
Added -both option
@
text
@d279 1
a279 1
" -start <test> like all, but start at <test>",
d676 26
a701 9
} else if (strcmp(argv[i], "-start") == 0) {
if (argc <= i)
usage();
i++;
ForEachTest (j) {
if (strcmp (argv[i], test[j].option) == 0) {
int k;
for (k = j; test[k].option != NULL; k++) {
doit[k] = True;
a702 1
break;
d704 3
a706 4
}
if (test[j].option == NULL)
usage();
foundOne = True;
d802 1
a802 1
printf("x11perf - X11 performance program, version 1.1\n");
@
2.18
log
@Make it easier to check out effects of backing store on performance.
@
text
@d34 3
a36 4
static Bool drawToFakeServer = False;
static Pixmap tileToQuery = None;
static Bool labels = False;
static Bool xorMode = False;
d38 10
d284 1
d338 1
a338 1
void DoHardwareSync(xp, p)
d341 1
d345 1
a345 1
for (i = 0; i != p->reps; i++) {
d352 1
a352 1
NullInitProc, DoHardwareSync, NullProc, NullProc, False, 0,
d416 1
a416 1
double DoTest(xp, test, label)
d419 1
a419 1
char *label;
d426 1
a426 1
(*test->proc) (xp, &test->parms);
d438 1
a438 1
Bool CalibrateTest(xp, test, seconds, usecperobj)
d449 2
a450 1
int reps, exponent;
d459 2
a460 3
if (fixedReps) {
test->parms.reps = fixedReps;
return True;
a463 1
test->parms.reps = reps;
d466 3
a468 2
if (! ((*test->init) (xp, &test->parms))) {
return False;
d474 1
a474 1
(*test->proc) (xp, &test->parms);
d481 1
a481 1
if (reps != test->parms.reps) {
d485 2
a486 2
usecs / (double)(test->parms.reps * test->parms.objects);
return True;
d510 1
a510 2
test->parms.reps = reps;
return True;
d514 1
a514 1
void CreatePerfGCs(xp)
d516 1
d522 1
a522 1
if (xorMode) {
d578 1
a578 1
void DisplayStatus(d, w, tgc, message, test)
a579 2
Window w;
GC tgc;
d585 1
a585 1
XClearWindow(d, w);
d589 1
a589 1
XDrawString(d, w, tgc, 10, 13, s, strlen(s));
d593 44
a646 2
int repeat = 5;
int seconds = 5;
a648 2
Window status;
GC tgc;
d720 2
d760 20
a779 7
if (test[i].children) {
for (child = 0; subs[child] != 0; child++) {
printf ("%s (%d kids)\n", test[i].label, subs[child]);
}
} else {
printf ("%s\n", test[i].label);
}
d841 3
d845 3
a847 14
int child = 0;
char label[100];
int reps = test[i].parms.reps;
double time, totalTime;
CreatePerfGCs(&xparms);
while (1) {
if (test[i].children) {
test[i].parms.objects = subs[child];
if (test[i].parms.objects == 0)
break;
sprintf (label, "%s (%d kids)",
test[i].label, test[i].parms.objects);
} else {
d849 2
a850 9
}
DisplayStatus(xparms.d, status, tgc, "Calibrating", label);
if (CalibrateTest(&xparms, &test[i], seconds, &time)) {
DisplayStatus(xparms.d, status, tgc, "Testing", label);
XDestroySubwindows(xparms.d, xparms.w);
XClearWindow(xparms.d, xparms.w);
(void)(*test[i].init) (&xparms, &test[i].parms);
/* Create clip windows if requested */
CreateClipWindows(&xparms, test[i].clips);
d852 6
a857 7
totalTime = 0.0;
for (j = 0; j != repeat; j++) {
time = DoTest(&xparms, &test[i], label);
totalTime += time;
ReportTimes (time,
test[i].parms.reps * test[i].parms.objects,
label, False);
d859 4
a862 4
if (repeat > 1) {
ReportTimes(totalTime,
repeat * test[i].parms.reps * test[i].parms.objects,
label, True);
a863 8
(*test[i].cleanup) (&xparms, &test[i].parms);
DestroyClipWindows(&xparms, test[i].clips);
} else {
/* Test failed to initialize properly */
}
printf ("\n");
fflush(stdout);
if (!test[i].children)
d865 14
a878 5
child++;
}
DestroyPerfGCs(&xparms);
}
}
@
2.17
log
@Added (in comment) backing-store, for comparing how it affects performance
@
text
@d352 2
d355 9
d365 2
a366 1
/* xswa.backing_store = Always; See if backing store costs anything */
d369 2
a370 1
XChangeWindowAttributes (xp->d, w, CWOverrideRedirect, &xswa);
@
2.16
log
@Added -start option
@
text
@d354 1
@
2.15
log
@*** empty log message ***
@
text
@d270 1
d613 17
a629 1
} else if (strcmp (argv[i], "-sync") == 0) {
d808 1
@
2.14
log
@Added generation of labels.
Added average timings for a test
@
text
@d270 1
a270 1
" -labels generate test labels for use by mungeall.sh",
@
2.13
log
@Allow -reps n to specify number of iterations within a test
Allow -subs at end to specify list of number of windows
@
text
@d36 1
a36 1
d167 1
a167 1
void ReportTimes(usecs, n, str)
d181 7
a187 2
printf("%6d reps @@ %7.4f msec (%6.1f/sec): %s\n",
n, msecsperobj, objspersec, str);
d270 1
d390 1
a390 1
DoTest(xp, test, label)
a403 1
ReportTimes (time, test->parms.reps * test->parms.objects, label);
d408 1
d610 2
d672 17
d692 1
a692 1
printf("x11perf - X11 performance program, version 1.0\n");
d695 1
a695 1
printf ("%s server on %s from %s\n",
d750 1
a750 1
double junk;
d764 1
a764 1
if (CalibrateTest(&xparms, &test[i], seconds, &junk)) {
d772 13
a784 2
for (j = 0; j != repeat; j++)
DoTest (&xparms, &test[i], label);
@
2.12
log
@Added ability to specify -xor for gcs
@
text
@d25 1
d47 2
d268 2
d426 4
d632 20
@
2.11
log
@Fixed gcs to turn of graphics_exposures, which means we don't get zillions
of NoExpose events.
@
text
@d36 2
d264 1
d481 14
a494 3
gcv.foreground = xp->background;
gcv.background = xp->foreground;
xp->bggc = XCreateGC(xp->d, xp->w,
d496 3
a498 4
gcv.foreground = xp->foreground;
gcv.background = xp->background;
xp->fggc = XCreateGC(xp->d, xp->w,
d500 1
d621 2
@
2.10
log
@Allow screens other than 0
Set up status window with BlackPixel and WhitePixel
@
text
@d476 2
d480 2
a481 1
xp->bggc = XCreateGC(xp->d, xp->w, GCForeground | GCBackground , &gcv);
d485 2
a486 1
xp->fggc = XCreateGC(xp->d, xp->w, GCForeground | GCBackground , &gcv);
@
2.9
log
@XWarpPointer out of benchmark window
@
text
@d27 1
a27 1
#include <sys/time.h>
d258 1
a258 1
" -draw draw after each test -- pmax only",
d339 1
a339 1
w = XCreateSimpleWindow (xp->d, RootWindow (xp->d, 0),
d438 2
a439 1
/* The test can't do the number of reps as we asked for. Give up */
d541 4
a544 4
int i, j;
int numTests; /* Even though the linker knows, we don't. */
char hostname[100];
char *displayName;
d546 8
a553 6
int repeat = 5;
int seconds = 5;
Bool foundOne = False;
Bool synchronous = False;
Window status;
GC tgc;
d618 1
d627 1
d631 3
a633 1
time to blank to a suitable large number, like 3 hours. */
d637 1
a637 1
XSetScreenSaver(xparms.d, 3 * 3600, ssInterval, ssPreferBlanking,
d642 1
a642 1
XCreatePixmap(xparms.d, RootWindow (xparms.d, 0), 32, 32, 1);
d647 1
a647 1
AllocateColor(xparms.d, foreground, BlackPixel(xparms.d, 0));
d649 1
a649 1
AllocateColor(xparms.d, background, WhitePixel(xparms.d, 0));
d652 4
a655 2
tgc = XCreateGC(xparms.d, status, 0, NULL);
d662 2
a663 2
all MIT-derived servers it will slow window creation/configuration
performance. */
@
2.8
log
@Made CalibrateTest give up if it ever gets back a DIFFERENT number of reps than it asked for
@
text
@d553 1
a553 1
int ssTimeout, ssIntervalReturn, ssPreferBlanking, ssAllowExposures;
d625 4
a628 2
/* ||| Doesn't seem to work so well.
XGetScreenSaver(xparms.d, &ssTimeout, &ssIntervalReturn, &ssPreferBlanking,
d630 2
a631 3
XForceScreenSaver(xparms.d, ScreenSaverReset);
XSetScreenSaver(xparms.d, 0, 0, DefaultBlanking, DefaultExposures);
*/
d651 6
d705 3
a707 2
/*
XSetScreenSaver(xparms.d, ssTimeout, ssIntervalReturn, ssPreferBlanking,
a708 1
*/
@
2.7
log
@Calibrate calculates usecperobj a little better
@
text
@d309 1
a309 1
image = XGetImage(xp->d, xp->w, 1, 1, 1, 1, ~0, ZPixmap);
d437 2
a438 2
if (reps > test->parms.reps) {
/* The test can't do as many reps as we asked for. Give up */
@
2.6
log
@Raise minimum calibration time to 2 seconds, just to get rid of cache
effects better, and get a more accurate handle.
@
text
@d439 2
a440 1
*usecperobj = usecs / (double)test->parms.reps;
d453 1
a453 1
*usecperobj = usecs / (double)reps;
@
2.5
log
@Parameters to all routines now (xp, p)
MAXROWS used in all routines
Junked most global communication variables
@
text
@d404 2
a405 2
#define goal 1500000.0 /* Try to get up to 1.5 seconds */
#define enough 1000000.0 /* But settle for 1.0 seconds */
d412 2
a413 1
reps to last more than a second.
@
2.4
log
@All syncs use harder hardware sync rather than just XSync.
# objects/second rounded to 3 significant digits.
@
text
@d1 23
d33 1
a33 1
static Bool drawToGPX = False;
d36 5
a42 1
int fgPixel, bgPixel;
d46 6
a51 5
static XRectangle ws[] = {
{300, 280, 90, 90},
{150, 250, 90, 90},
{450, 310, 90, 90}
};
d55 4
a83 1
d88 1
a88 2
if (firsttime)
{
d95 1
a95 2
if (current_time.low < basetime.low)
{
a104 2
/* time related stuff */
d121 2
a122 1
double ElapsedTime()
d133 1
a133 1
(1000000.0 * (double)(stop.tv_sec - start.tv_sec));
d171 1
d175 1
d180 6
a185 1
/* generic X stuff */
d194 2
a195 2
int *pargc; /* MODIFIED */
char **argv; /* MODIFIED */
d197 4
a200 4
int argc = *pargc;
char **pargv = argv+1;
char *displayname = NULL;
int i;
d202 1
a202 1
for (i = 1; i < argc; i++) {
d213 2
a214 3
while (i<argc)
*pargv++ = argv[i++];
break;
d228 1
a228 1
char *display_name;
d230 1
a230 1
Display *d;
d232 7
a238 7
d = XOpenDisplay(display_name);
if (d == NULL) {
fprintf (stderr, "%s: unable to open display '%s'\n",
program_name, XDisplayName (display_name));
usage ();
/* doesn't return */
}
d240 1
a240 1
return(d);
d243 3
a245 1
/* stuff just for perf */
d247 1
d250 2
a251 2
char **cpp;
int i = 0;
d269 1
a269 2
while (test[i].option != NULL)
{
d275 6
d284 3
a286 3
void HardwareSync(d, w)
Display *d;
Window w;
a287 13
if (w == NULL) {
XSync (d, True);
} else {
/*
* Some graphics hardware allows the server to claim it is done,
* while in reality the hardware is busily working away. So fetch
* a pixel from the window that was drawn to, which should be
* enough to make the server wait for the graphics hardware.
*/
XImage *i;
i = XGetImage(d, w, 1, 1, 1, 1, ~0, ZPixmap);
XDestroyImage(i);
}
d290 6
a295 2
/* Main window created (if any) that the current benchmark draws to. */
static Window perfWindow;
d297 3
a299 4
DoTest(d, test, label)
Display *d;
Test *test;
char *label;
d301 7
a307 2
double time;
int ret_width, ret_height;
d309 3
a311 4
HardwareSync (d, perfWindow);
InitTimes ();
(*test->proc) (d, &test->parms);
HardwareSync(d, perfWindow);
d313 9
a321 7
time = ElapsedTime();
ReportTimes (time, test->parms.reps * test->parms.objects, label);
if (drawToGPX)
XQueryBestSize(d, TileShape, tileToQuery,
32, 32, &ret_width, &ret_height);
if (test->passCleanup != NULL)
(*test->passCleanup) (d, &test->parms);
d324 5
d330 4
a333 3
Window CreatePerfWindow(d, x, y, width, height)
Display *d;
int width, height, x, y;
d339 4
a342 4
w = XCreateSimpleWindow (
d, RootWindow (d, 0), x, y, width, height, 1, fgPixel, bgPixel);
XChangeWindowAttributes (d, w, CWOverrideRedirect, &xswa);
XMapWindow (d, w);
d347 2
a348 3
void CreateClipWindows(display, clips)
Display *display;
d352 1
d354 1
d356 3
a358 3
for (j = 0; j < clips; j++) {
clipWindows[j] = CreatePerfWindow(display,
ws[j].x, ws[j].y, ws[j].width, ws[j].height);
d362 3
a364 2
void DestroyClipWindows(display, clips)
Display *display;
d370 2
a371 2
for (j = 0; j < clips; j++) {
XDestroyWindow(display, clipWindows[j]);
d376 7
d384 19
a402 4
Bool CalibrateTest(d, test, seconds)
Display *d;
Test *test;
int seconds;
d404 4
d411 2
a412 3
/* Attempt to get an idea how long each rep lasts by first getting enough
reps to last more than a second. Then set p->reps to run long
enough to do enough reps to last as many seconds as the guy asked for.
d420 4
a423 8
if (test->init != NULL) {
if (! ((*test->init) (d, &test->parms))) {
return False;
}
/* Create clip windows if requested */
if (perfWindow != NULL) {
CreateClipWindows(d, test->clips);
}
d425 3
a427 1
HardwareSync(d, perfWindow);
d429 7
a435 10
(*test->proc) (d, &test->parms);
HardwareSync(d, perfWindow);
usecs = ElapsedTime();
if (test->passCleanup != NULL)
(*test->passCleanup) (d, &test->parms);
if (test->cleanup != NullProc)
(*test->cleanup) (d, &test->parms);
if (perfWindow != NULL) {
DestroyClipWindows(d, test->clips);
}
d438 1
d442 1
a442 1
if (usecs >= 1000000.0) break;
d444 2
a445 2
/* Assume that it took 1/100 sec if we didn't get a clock tick. */
if (usecs == 0.0) usecs = 10000.0;
d447 2
a448 3
/* Try to get up to 1.5 seconds. */
reps = (int) (1500000.0 * (double)reps / usecs) + 1;
d451 1
d468 2
a469 5
void CreatePerfStuff(d, count, width, height, w, bggc, fggc)
Display *d;
int width, height, count;
Window *w;
GC *bggc, *fggc;
a471 2
XSetWindowAttributes xswa;
int i;
d473 3
a475 4
xswa.override_redirect = True;
for (i = 0; i < count; i++) {
w[i] = CreatePerfWindow(d, 2+i*width, 2+i*height, width, height);
}
d477 4
a480 4
if (count != 0) {
/* Stash away main graphics window */
perfWindow = w[0];
}
d482 5
a486 44
if (bggc != NULL) {
#ifdef testingxor
gcv.foreground = bgPixel ^ fgPixel;
gcv.background = ~gcv.foreground;
gcv.function = GXinvert;
gcv.plane_mask = bgPixel ^ fgPixel;
*bggc = XCreateGC(d, w[0],
GCForeground | GCBackground | GCFunction | GCPlaneMask, &gcv);
#else
# ifdef testingandor
gcv.foreground = 1;
gcv.background = 0;
gcv.function = GXor;
gcv.plane_mask = 1;
*bggc = XCreateGC(d, w[0],
GCForeground | GCBackground | GCFunction | GCPlaneMask, &gcv);
# else
gcv.foreground = bgPixel;
gcv.background = fgPixel;
*bggc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
# endif
#endif
}
if (fggc != NULL) {
#ifdef testingxor
gcv.foreground = bgPixel ^ fgPixel;
gcv.background = ~gcv.foreground;
gcv.function = GXxor;
*fggc = XCreateGC(d, w[0],
GCForeground | GCBackground | GCFunction, &gcv);
#else
# ifdef testingandor
gcv.foreground = 0;
gcv.background = 1;
gcv.function = GXand;
*fggc = XCreateGC(d, w[0],
GCForeground | GCBackground | GCFunction, &gcv);
# else
gcv.foreground = fgPixel;
gcv.background = bgPixel;
*fggc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
# endif
#endif
}
d515 18
a532 1
Window root;
d542 1
a542 1
Display * display;
d545 4
a548 2
Bool foundOne = False;
Bool synchronous = False;
d553 6
d560 1
d564 1
d567 1
a567 1
for (i = 1; i < argc; i++) {
d575 1
a575 1
drawToGPX = True;
d612 1
a612 1
display = Open_Display (displayName);
d616 1
a616 1
ServerVendor (display), DisplayString (display), hostname);
d619 1
a619 1
ServerVendor (display), DisplayString (display));
d624 1
a624 1
XGetScreenSaver(display, &ssTimeout, &ssIntervalReturn, &ssPreferBlanking,
d626 2
a627 2
XForceScreenSaver(display, ScreenSaverReset);
XSetScreenSaver(display, 0, 0, DefaultBlanking, DefaultExposures);
d629 4
a632 3
root = RootWindow (display, 0);
if (drawToGPX) {
tileToQuery = XCreatePixmap(display, root, 32, 32, 1);
d636 8
a643 2
fgPixel = AllocateColor(display, foreground, BlackPixel(display, 0));
bgPixel = AllocateColor(display, background, WhitePixel(display, 0));
d646 7
a652 1
XSynchronize (display, True);
d658 3
a665 2
if (reps > 10)
test[i].parms.reps = reps/test[i].parms.objects;
d671 6
a676 4
perfWindow = NULL;
if (CalibrateTest(display, &test[i], seconds)) {
if (test[i].init != NULL)
(void)(*test[i].init) (display, &test[i].parms);
d678 1
a678 3
if (perfWindow != NULL) {
CreateClipWindows(display, test[i].clips);
}
d680 4
a683 7
for (j = 0; j < repeat; j++)
DoTest (display, &test[i], label);
if (test[i].cleanup != NullProc)
(*test[i].cleanup) (display, &test[i].parms);
if (perfWindow != NULL) {
DestroyClipWindows(display, test[i].clips);
}
d692 1
d695 1
d697 1
a697 1
XSetScreenSaver(display, ssTimeout, ssIntervalReturn, ssPreferBlanking,
@
2.3
log
@Self-timing calibration, better fg/bg color parsing
@
text
@d94 1
a94 2
void GetTime (usec)
int *usec;
d100 1
a100 2
if (stop.tv_usec < start.tv_usec)
{
d104 2
a105 2
*usec = stop.tv_usec - start.tv_usec +
(1000000 * (stop.tv_sec - start.tv_sec));
d108 2
a109 4
void ReportTimes(usec, n, str)
int usec;
int n;
char *str;
d111 2
a112 1
int usecperobj, objpersec;
d114 17
a130 4
usecperobj = (usec * 10) / n;
objpersec = (int) ((double) n * 1000000.0 / (double) usec + 0.5);
printf("%6d reps @@ %2d.%04d msec (%4d/sec): %s\n",
n, usecperobj/10000, usecperobj%10000, objpersec, str);
d133 17
d242 1
a242 1
void EndSync(d, w)
d247 1
a247 1
XSync (d, 0);
d269 1
a269 1
int r;
d272 1
a272 1
XSync (d, True);
d275 1
a275 1
EndSync(d, perfWindow);
d277 2
a278 2
GetTime (&r);
ReportTimes (r, test->parms.reps * test->parms.objects, label);
d336 2
a337 2
int usecs;
int reps, exponent;
d358 1
a358 1
XSync(d, 0);
d361 2
a362 2
EndSync(d, perfWindow);
GetTime(&usecs);
d375 1
a375 1
if (usecs >= 1000000) break;
d378 1
a378 1
if (usecs == 0) usecs = 10000;
d381 1
a381 1
reps = (int) (1500000.0 * (double)reps / (double)usecs) + 1;
d385 1
a385 2
reps = (int) ((double)seconds * 1000000.0 * (double)reps
/ (double)usecs) + 1;
d387 2
a388 2
/* Now round reps up to 1 digit accuracy, so we don't get really weird
numbers coming out */
a625 1
printf("FAILED TEST: %s\n", test[i].label);
@
2.2
log
@Massive changes, I'm not going to go into details.
@
text
@d20 3
a22 3
{150, 150, 90, 90},
{300, 180, 90, 90},
{450, 210, 90, 90}
d110 2
a111 2
void ReportTimes(r, n, str)
int r;
d115 6
a120 2
r /= n;
printf("%6d repetitions @@ %2d.%03d millisec/%s\n", n, r/1000, r%1000, str);
d192 2
a193 1
" -repeat <n>\t do tests <n> times (default = 5)",
d215 1
a215 4
/* Main window created (if any) that the current benchmark draws to. */
static Window perfWindow;
DoTest(d, test, label)
d217 1
a217 2
Test *test;
char *label;
d219 1
a219 7
int r;
int ret_width, ret_height;
XSync (d, 0);
InitTimes ();
(*test->proc) (d, &test->parms);
if (perfWindow == NULL) {
d229 1
a229 1
i = XGetImage(d, perfWindow, 1, 1, 1, 1, ~0, ZPixmap);
d232 1
d234 16
d277 98
d387 1
a387 1
w[i] = CreatePerfWindow(d, 50+i*width, 50+i*height, width, height);
d441 4
a444 3
void CreateClipWindows(display, clips)
Display *display;
int clips;
d446 2
a447 1
int j;
d449 2
a450 6
if (clips > MAXCLIP) clips = MAXCLIP;
for (j = 0; j < clips; j++) {
clipWindows[j] = CreatePerfWindow(display,
ws[j].x, ws[j].y, ws[j].width, ws[j].height);
}
} /* CreateClipWindows */
d452 11
a462 9
void DestroyClipWindows(display, clips)
Display *display;
int clips;
{
int j;
if (clips > MAXCLIP) clips = MAXCLIP;
for (j = 0; j < clips; j++) {
XDestroyWindow(display, clipWindows[j]);
d464 2
a465 1
} /* DestroyClipWindows */
a466 2
d479 1
d483 4
d505 1
a505 1
if (repeat == 0)
d507 6
d548 6
d560 2
a561 5
fgPixel = BlackPixel(display, 0);
bgPixel = WhitePixel(display, 0);
if (foreground != NULL) {
/* Try to allocate a foreground color as specified */
XColor def, cdef;
a562 20
if (XAllocNamedColor(display,
XDefaultColormap(display, DefaultScreen(display)),
foreground, &def, &cdef)) {
fgPixel = def.pixel;
} else {
(void) fprintf(stderr, "Cannot allocate color %s\n", foreground);
}
}
if (background != NULL) {
/* Try to allocate a background color as specified */
XColor def, cdef;
if (XAllocNamedColor(display,
XDefaultColormap(display, DefaultScreen(display)),
background, &def, &cdef)) {
bgPixel = def.pixel;
} else {
(void) fprintf(stderr, "Cannot allocate color %s\n", background);
}
}
d577 1
a577 1
sprintf (label, "%s (%d children)",
d583 3
a585 2
if (test[i].init == NULL ||
((*test[i].init) (display, &test[i].parms))) {
d590 1
d600 1
d609 4
@
2.1
log
@Make any benchmark that creates a window to write to actually try to read
data back from that window. This insures that machines like the GPX don't
lie about being done with an operation, when in reality the graphics
accelerator is chugging away.
@
text
@d17 10
d331 27
d365 1
d373 3
d381 1
a381 1
test[j].doit = True;
d406 1
a406 1
test[j].doit = True;
d463 1
a463 1
if (test[i].doit) {
d476 2
a478 2
else
strcpy (label, test[i].label);
d480 16
a495 6
if (test[i].init != NullProc)
(*test[i].init) (display, &test[i].parms);
for (j = 0; j < repeat; j++)
DoTest (display, &test[i], label);
if (test[i].cleanup != NullProc)
(*test[i].cleanup) (display, &test[i].parms);
@
2.0
log
@version from /usr/src/pmax
@
text
@d200 3
d214 14
a227 1
XSync (d, 0);
d253 2
d267 1
a267 1
w[i] = CreatePerfWindow(d, 50, 50, width, height);
d270 5
d438 1
@
1.6
log
@No changes
@
text
@@
1.5
log
@Added -fg -bg capabilities
Added tiled rectangles
@
text
@d375 1
@
1.4
log
@Added stuff for testing weird functions with planemask
@
text
@d13 4
d20 2
a21 2
unsigned long low;
unsigned long high;
d25 2
a26 2
long tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
d30 2
a31 2
int tz_minuteswest; /* of Greenwich */
int tz_dsttime; /* type of dst correction to apply */
d181 2
d231 1
a231 2
d, RootWindow (d, 0), x, y, width, height, 1,
BlackPixel (d, 0), WhitePixel (d, 0));
d237 1
a237 1
void CreatePerfStuff(d, count, width, height, w, whitegc, blackgc)
d241 1
a241 1
GC *whitegc, *blackgc;
d252 3
a254 3
if (whitegc != NULL) {
#ifdef new
gcv.foreground = WhitePixel(d, 0) ^ BlackPixel(d, 0);
d257 2
a258 2
gcv.plane_mask = WhitePixel(d, 0) ^ BlackPixel(d, 0);
*whitegc = XCreateGC(d, w[0],
d261 12
a272 3
gcv.foreground = WhitePixel(d, 0);
gcv.background = BlackPixel(d, 0);
*whitegc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
d275 3
a277 3
if (blackgc != NULL) {
#ifdef new
gcv.foreground = WhitePixel(d, 0) ^ BlackPixel(d, 0);
d280 1
a280 1
*blackgc = XCreateGC(d, w[0],
d283 11
a293 3
gcv.foreground = BlackPixel(d, 0);
gcv.background = WhitePixel(d, 0);
*blackgc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
d318 31
a348 1
foundOne = True;;
a349 26
else
if (strcmp (argv[i], "-sync") == 0) {
synchronous = True;
}
else if (strcmp (argv[i], "-draw") == 0) {
drawToGPX = True;
}
else
if (strcmp (argv[i], "-repeat") == 0) {
if (argc <= i)
usage ();
repeat = atoi (argv[++i]);
if (repeat == 0)
usage ();
}
else {
ForEachTest (j) {
if (strcmp (argv[i], test[j].option) == 0) {
test[j].doit = True;
goto LegalOption;
}
}
usage ();
LegalOption:
foundOne = True;
}
d368 27
@
1.3
log
@no change
@
text
@d248 8
d259 1
d262 7
d272 1
@
1.2
log
@Susan's changes to display after each test on GPX
@
text
@@
1.1
log
@Initial revision
@
text
@d10 3
d175 1
d200 1
d206 1
a206 1
GetTime (&r);
d208 3
d285 3
d322 3
@