1 /***************************************************************************** 2 Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. 3 4 All Rights Reserved 5 6 Permission to use, copy, modify, and distribute this software and its 7 documentation for any purpose and without fee is hereby granted, 8 provided that the above copyright notice appear in all copies and that 9 both that copyright notice and this permission notice appear in 10 supporting documentation, and that the name of Digital not be 11 used in advertising or publicity pertaining to distribution of the 12 software without specific, written prior permission. 13 14 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 15 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 16 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 17 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 18 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 19 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 20 SOFTWARE. 21 22 ******************************************************************************/ 23 24 #if HAVE_CONFIG_H 25 #include "config.h" 26 #endif 27 28 #ifndef VMS 29 #include <X11/Xlib.h> 30 #include <stdlib.h> 31 #include <X11/Xutil.h> 32 #else 33 #include <decw$include/Xlib.h> 34 #include <decw$include/Xutil.h> 35 #endif 36 #if defined(XlibSpecificationRelease) && XlibSpecificationRelease >= 5 37 #include <X11/Xfuncs.h> 38 #endif 39 #include <stddef.h> 40 #include <X11/extensions/Xrender.h> 41 42 #define POLY 1000 /* # (small) items in poly calls */ 43 #define MAXROWS 40 /* Max rows of items in poly calls */ 44 #define MAXCOLS 25 /* Max columns of items */ 45 46 #define WIDTH 600 /* Size of large window to work within */ 47 #define HEIGHT 600 48 49 #define CHILDSIZE 8 /* Size of children on windowing tests */ 50 #define CHILDSPACE 4 /* Space between children */ 51 52 #define BigTile ((char *)2) /* Big tile/stipple */ 53 #define OddTile ((char *)1) /* Odd sized tile/stipple */ 54 55 #define PictStandardNative 5 56 57 typedef unsigned char Version; 58 59 #define VERSION1_2 ((Version)(1 << 0)) 60 #define VERSION1_3 ((Version)(1 << 1)) 61 #define VERSION1_4 ((Version)(1 << 2)) 62 #define VERSION1_5 ((Version)(1 << 3)) 63 #define VERSION1_6 ((Version)(1 << 4)) 64 #define V1_2ONLY VERSION1_2 65 #define V1_2FEATURE (VERSION1_2 | VERSION1_3 | VERSION1_4 | VERSION1_5 | VERSION1_6) 66 #define V1_3FEATURE (VERSION1_3 | VERSION1_4 | VERSION1_5 | VERSION1_6) 67 #define V1_4FEATURE (VERSION1_4 | VERSION1_5 | VERSION1_6) 68 #define V1_5FEATURE (VERSION1_5 | VERSION1_6) 69 #define V1_6FEATURE (VERSION1_6) 70 71 typedef struct _Parms { 72 /* Required fields */ 73 int objects; /* Number of objects to process in one X call */ 74 75 /* Optional fields. (Wouldn't object-oriented programming be nice ?) */ 76 int special; /* Usually size of objects to paint */ 77 const char *font, *bfont; 78 int fillStyle; /* Solid, transparent stipple, opaque stipple, tile */ 79 } ParmRec, *Parms; 80 81 typedef struct _XParms { 82 Display *d; 83 Window w; 84 Pixmap p; 85 GC fggc; 86 GC bggc; 87 GC ddfggc; 88 GC ddbggc; 89 Picture w_picture; 90 Picture p_picture; 91 unsigned long foreground; 92 unsigned long background; 93 unsigned long ddbackground; 94 XVisualInfo vinfo; 95 Bool pack; 96 Version version; 97 Bool save_under; 98 int backing_store; 99 unsigned long planemask; 100 int func; 101 int format; 102 Colormap cmap; 103 } XParmRec, *XParms; 104 105 typedef int (*InitProc)(XParms xp, Parms p, int64_t reps); 106 typedef void (*Proc)(XParms xp, Parms p, int64_t reps); 107 typedef void (*CleanupProc)(XParms xp, Parms p); 108 109 typedef enum { 110 WINDOW, /* Windowing test, rop, planemask have no affect */ 111 ROP, /* Graphics test, rop, planemask has some affect */ 112 PLANEMASK, /* Graphics test, rop no affect, planemask some affect */ 113 NONROP, /* Graphics or overhead test, rop has no affect */ 114 COMP /* Graphics test, render op */ 115 } TestType; 116 117 typedef struct _Test { 118 const char *option; /* Name to use in prompt line */ 119 const char *label; /* Fuller description of test */ 120 const char *label14; /* Labels that are different in Version 1.4 */ 121 InitProc init; /* Initialization procedure */ 122 Proc proc; /* Timed benchmark procedure */ 123 CleanupProc passCleanup;/* Cleanup between repetitions of same test */ 124 CleanupProc cleanup; /* Cleanup after test */ 125 Version versions; /* Test in 1.2 only, 1.3 only, or both */ 126 TestType testType; /* Windowing, graphics rop, graphics non-rop */ 127 int clips; /* Number of obscuring windows to force clipping*/ 128 ParmRec parms; /* Parameters passed to test procedures */ 129 } Test; 130 131 extern void NullProc(XParms xp, Parms p); 132 extern int NullInitProc(XParms xp, Parms p, int64_t reps); 133 134 extern Test test[]; 135 136 extern int abortTest; 137 138 extern void AbortTest (void) _X_NORETURN; 139 140 #define CheckAbort() if (abortTest) AbortTest () 141 #define ForEachTest(x) for (x = 0; test[x].option != NULL; x++) 142 143 144 /* do_arcs.c */ 145 extern int InitCircles ( XParms xp, Parms p, int64_t reps ); 146 extern int InitPartCircles ( XParms xp, Parms p, int64_t reps ); 147 extern int InitChordPartCircles ( XParms xp, Parms p, int64_t reps ); 148 extern int InitSlicePartCircles ( XParms xp, Parms p, int64_t reps ); 149 extern int InitWideCircles ( XParms xp, Parms p, int64_t reps ); 150 extern int InitPartWideCircles ( XParms xp, Parms p, int64_t reps ); 151 extern int InitDashedCircles ( XParms xp, Parms p, int64_t reps ); 152 extern int InitWideDashedCircles ( XParms xp, Parms p, int64_t reps ); 153 extern int InitDoubleDashedCircles ( XParms xp, Parms p, int64_t reps ); 154 extern int InitWideDoubleDashedCircles ( XParms xp, Parms p, int64_t reps ); 155 extern int InitEllipses ( XParms xp, Parms p, int64_t reps ); 156 extern int InitPartEllipses ( XParms xp, Parms p, int64_t reps ); 157 extern int InitChordPartEllipses ( XParms xp, Parms p, int64_t reps ); 158 extern int InitSlicePartEllipses ( XParms xp, Parms p, int64_t reps ); 159 extern int InitWideEllipses ( XParms xp, Parms p, int64_t reps ); 160 extern int InitPartWideEllipses ( XParms xp, Parms p, int64_t reps ); 161 extern int InitDashedEllipses ( XParms xp, Parms p, int64_t reps ); 162 extern int InitWideDashedEllipses ( XParms xp, Parms p, int64_t reps ); 163 extern int InitDoubleDashedEllipses ( XParms xp, Parms p, int64_t reps ); 164 extern int InitWideDoubleDashedEllipses ( XParms xp, Parms p, int64_t reps ); 165 extern void DoArcs ( XParms xp, Parms p, int64_t reps ); 166 extern void DoFilledArcs ( XParms xp, Parms p, int64_t reps ); 167 extern void EndArcs ( XParms xp, Parms p ); 168 169 /* do_blt.c */ 170 extern int InitScroll ( XParms xp, Parms p, int64_t reps ); 171 extern void DoScroll ( XParms xp, Parms p, int64_t reps ); 172 extern void MidScroll ( XParms xp, Parms p ); 173 extern void EndScroll ( XParms xp, Parms p ); 174 extern int InitCopyWin ( XParms xp, Parms p, int64_t reps ); 175 extern int InitCopyPix ( XParms xp, Parms p, int64_t reps ); 176 extern int InitGetImage ( XParms xp, Parms p, int64_t reps ); 177 extern int InitPutImage ( XParms xp, Parms p, int64_t reps ); 178 extern void DoCopyWinWin ( XParms xp, Parms p, int64_t reps ); 179 extern void DoCopyPixWin ( XParms xp, Parms p, int64_t reps ); 180 extern void DoCopyWinPix ( XParms xp, Parms p, int64_t reps ); 181 extern void DoCopyPixPix ( XParms xp, Parms p, int64_t reps ); 182 extern void DoGetImage ( XParms xp, Parms p, int64_t reps ); 183 extern void DoPutImage ( XParms xp, Parms p, int64_t reps ); 184 #ifdef MITSHM 185 extern int InitShmPutImage ( XParms xp, Parms p, int64_t reps ); 186 extern int InitShmGetImage ( XParms xp, Parms p, int64_t reps ); 187 extern void DoShmPutImage ( XParms xp, Parms p, int64_t reps ); 188 extern void DoShmGetImage ( XParms xp, Parms p, int64_t reps ); 189 extern void EndShmPutImage ( XParms xp, Parms p ); 190 extern void EndShmGetImage ( XParms xp, Parms p ); 191 #endif 192 extern void MidCopyPix ( XParms xp, Parms p ); 193 extern void EndCopyWin ( XParms xp, Parms p ); 194 extern void EndCopyPix ( XParms xp, Parms p ); 195 extern void EndGetImage ( XParms xp, Parms p ); 196 extern int InitCopyPlane ( XParms xp, Parms p, int64_t reps ); 197 extern void DoCopyPlane ( XParms xp, Parms p, int64_t reps ); 198 199 int 200 InitCompositeWin(XParms xp, Parms p, int64_t reps); 201 202 void 203 EndCompositeWin (XParms xp, Parms p); 204 205 void 206 DoCompositeWinWin (XParms xp, Parms p, int64_t reps); 207 208 int 209 InitCompositePix(XParms xp, Parms p, int64_t reps); 210 211 void 212 EndCompositePix (XParms xp, Parms p); 213 214 void 215 DoCompositePixWin (XParms xp, Parms p, int64_t reps); 216 217 /* do_complex.c */ 218 extern int InitComplexPoly ( XParms xp, Parms p, int64_t reps ); 219 extern void DoComplexPoly ( XParms xp, Parms p, int64_t reps ); 220 extern void EndComplexPoly ( XParms xp, Parms p ); 221 extern int InitGeneralPoly ( XParms xp, Parms p, int64_t reps ); 222 extern void DoGeneralPoly ( XParms xp, Parms p, int64_t reps ); 223 224 /* do_dots.c */ 225 extern int InitDots ( XParms xp, Parms p, int64_t reps ); 226 extern void DoDots ( XParms xp, Parms p, int64_t reps ); 227 extern void EndDots ( XParms xp, Parms p ); 228 229 /* do_lines.c */ 230 extern int InitLines ( XParms xp, Parms p, int64_t reps ); 231 extern int InitWideLines ( XParms xp, Parms p, int64_t reps ); 232 extern int InitDashedLines ( XParms xp, Parms p, int64_t reps ); 233 extern int InitWideDashedLines ( XParms xp, Parms p, int64_t reps ); 234 extern int InitDoubleDashedLines ( XParms xp, Parms p, int64_t reps ); 235 extern int InitWideDoubleDashedLines ( XParms xp, Parms p, int64_t reps ); 236 extern void DoLines ( XParms xp, Parms p, int64_t reps ); 237 extern void EndLines ( XParms xp, Parms p ); 238 239 /* do_movewin.c */ 240 extern int InitMoveWindows ( XParms xp, Parms p, int64_t reps ); 241 extern void DoMoveWindows ( XParms xp, Parms p, int64_t reps ); 242 extern void EndMoveWindows ( XParms xp, Parms p ); 243 extern void DoResizeWindows ( XParms xp, Parms p, int64_t reps ); 244 extern int InitCircWindows ( XParms xp, Parms p, int64_t reps ); 245 extern void DoCircWindows ( XParms xp, Parms p, int64_t reps ); 246 extern void EndCircWindows ( XParms xp, Parms p ); 247 extern int InitMoveTree ( XParms xp, Parms p, int64_t reps ); 248 extern void DoMoveTree ( XParms xp, Parms p, int64_t reps ); 249 extern void EndMoveTree ( XParms xp, Parms p ); 250 251 /* do_rects.c */ 252 extern int InitRectangles ( XParms xp, Parms p, int64_t reps ); 253 extern void DoRectangles ( XParms xp, Parms p, int64_t reps ); 254 extern void DoOutlineRectangles ( XParms xp, Parms p, int64_t reps ); 255 extern void EndRectangles ( XParms xp, Parms p ); 256 257 /* do_segs.c */ 258 extern int InitSegments ( XParms xp, Parms p, int64_t reps ); 259 extern int InitDashedSegments ( XParms xp, Parms p, int64_t reps ); 260 extern int InitDoubleDashedSegments ( XParms xp, Parms p, int64_t reps ); 261 extern int InitHorizSegments ( XParms xp, Parms p, int64_t reps ); 262 extern int InitWideHorizSegments ( XParms xp, Parms p, int64_t reps ); 263 extern int InitVertSegments ( XParms xp, Parms p, int64_t reps ); 264 extern int InitWideVertSegments ( XParms xp, Parms p, int64_t reps ); 265 extern void DoSegments ( XParms xp, Parms p, int64_t reps ); 266 extern void EndSegments ( XParms xp, Parms p ); 267 268 /* do_simple.c */ 269 extern void DoNoOp ( XParms xp, Parms p, int64_t reps ); 270 extern void DoGetAtom ( XParms xp, Parms p, int64_t reps ); 271 extern void DoQueryPointer ( XParms xp, Parms p, int64_t reps ); 272 extern int InitGetProperty ( XParms xp, Parms p, int64_t reps ); 273 extern void DoGetProperty ( XParms xp, Parms p, int64_t reps ); 274 275 /* do_text.c */ 276 extern int InitText ( XParms xp, Parms p, int64_t reps ); 277 extern int InitText16 ( XParms xp, Parms p, int64_t reps ); 278 extern void DoText ( XParms xp, Parms p, int64_t reps ); 279 extern void DoText16 ( XParms xp, Parms p, int64_t reps ); 280 extern void DoPolyText ( XParms xp, Parms p, int64_t reps ); 281 extern void DoPolyText16 ( XParms xp, Parms p, int64_t reps ); 282 extern void DoImageText ( XParms xp, Parms p, int64_t reps ); 283 extern void DoImageText16 ( XParms xp, Parms p, int64_t reps ); 284 extern void ClearTextWin ( XParms xp, Parms p ); 285 extern void EndText ( XParms xp, Parms p ); 286 extern void EndText16 ( XParms xp, Parms p ); 287 #ifdef XFT 288 extern int InitAAText (XParms xp, Parms p, int64_t reps ); 289 extern void DoAAText (XParms xp, Parms p, int64_t reps ); 290 extern void EndAAText ( XParms xp, Parms p ); 291 #endif 292 293 /* do_traps.c */ 294 extern int InitTrapezoids ( XParms xp, Parms p, int64_t reps ); 295 extern void DoTrapezoids ( XParms xp, Parms p, int64_t reps ); 296 extern void EndTrapezoids ( XParms xp, Parms p ); 297 #if defined(XRENDER) && defined(XFT) 298 extern int InitFixedTraps ( XParms xp, Parms p, int64_t reps ); 299 extern void DoFixedTraps ( XParms xp, Parms p, int64_t reps ); 300 extern void EndFixedTraps ( XParms xp, Parms p ); 301 extern int InitFixedTrapezoids ( XParms xp, Parms p, int64_t reps ); 302 extern void DoFixedTrapezoids ( XParms xp, Parms p, int64_t reps ); 303 extern void EndFixedTrapezoids ( XParms xp, Parms p ); 304 #endif 305 306 /* do_tris.c */ 307 extern int InitTriangles ( XParms xp, Parms p, int64_t reps ); 308 extern void DoTriangles ( XParms xp, Parms p, int64_t reps ); 309 extern void EndTriangles ( XParms xp, Parms p ); 310 311 /* do_valgc.c */ 312 extern int InitGC ( XParms xp, Parms p, int64_t reps ); 313 extern void DoChangeGC ( XParms xp, Parms p, int64_t reps ); 314 extern void EndGC ( XParms xp, Parms p ); 315 316 /* do_windows.c */ 317 extern int CreateParents ( XParms xp, Parms p, int64_t reps ); 318 extern void MapParents ( XParms xp, Parms p, int64_t reps ); 319 extern void MapParentsCleanup ( XParms xp, Parms p ); 320 extern int InitCreate ( XParms xp, Parms p, int64_t reps ); 321 extern void CreateChildren ( XParms xp, Parms p, int64_t reps ); 322 extern void DestroyChildren ( XParms xp, Parms p ); 323 extern void EndCreate ( XParms xp, Parms p ); 324 extern int InitMap ( XParms xp, Parms p, int64_t reps ); 325 extern void UnmapParents ( XParms xp, Parms p, int64_t reps ); 326 extern void UnmapParentsCleanup ( XParms xp, Parms p); 327 extern int InitDestroy ( XParms xp, Parms p, int64_t reps ); 328 extern void DestroyParents ( XParms xp, Parms p, int64_t reps ); 329 extern void RenewParents ( XParms xp, Parms p ); 330 extern int InitPopups ( XParms xp, Parms p, int64_t reps ); 331 extern void DoPopUps ( XParms xp, Parms p, int64_t reps ); 332 extern void EndPopups ( XParms xp, Parms p ); 333 334 335 /***************************************************************************** 336 337 About x11perf: 338 339 Many graphics benchmarks assume that the graphics device is used to display the 340 output of a single fancy graphics application, and that the user gets his work 341 done on some other device, like a terminal. Such benchmarks usually measure 342 drawing speed for lines, polygons, text, etc. 343 344 Since workstations are not used as standalone graphics engines, but as 345 super-terminals, x11perf measures window management performance as well as 346 traditional graphics performace. x11perf includes benchmarks for the time it 347 takes to create and map windows (as when you start up an application); to map a 348 pre-existing set of windows onto the screen (as when you deiconify an 349 application or pop up a menu); and to rearrange windows (as when you slosh 350 windows to and fro trying to find the one you want). 351 352 x11perf also measures graphics performance for operations not normally used in 353 standalone graphics displays, but are nonetheless used frequently by X 354 applications. Such operations include CopyPlane (used by the PostScript 355 previewer), scrolling (used in text windows), and various stipples and tiles 356 (used for CAD and half-toning, respectively). 357 358 x11perf DOES NOT attempt to whittle down measurements to a single ``HeXStones'' 359 number. We consider such numbers to be uninformative at best and misleading at 360 worst. x11perf should be used to analyze particular strengths and weaknesses 361 of servers, and is most useful when used by a server writer who wants to 362 analyze and improve a server. 363 364 For repeatable results, x11perf should be run using a local connection on a 365 freshly-started server. The default configuration runs each test 5 times, in 366 order to see if each trial takes approximately the same amount of time. 367 Strange glitches should be examined; if non-repeatable I chalk them up to 368 daemons and network traffic. Each trial is run for 5 seconds, in order to 369 reduce random time differences. The number of objects processed per second is 370 displayed to 3 significant digits, but you'll be lucky on most UNIX system if 371 the numbers are actually consistent to 2 digits. 372 373 The current program is mostly the responsibility of Joel McCormack. It is 374 based upon the x11perf developed by Phil Karlton, Susan Angebranndt, and Chris 375 Kent, who wanted to assess performance differences between various servers. 376 Mary Walker, Todd Newman, and I added several tests in order to write and tune 377 the pmax (DECStation 3100) servers. For a general release to the world, I've 378 basically rewritten x11perf to ease making comparisons between widely varying 379 machines, to cover most important X functionality (the notable exception being 380 wide lines), and to exercise graphics operations in as many different 381 orientations and alignments as possible. 382 383 ******************************************************************************/ 384