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 >
Text File  |  1990-03-15  |  51KB  |  2,440 lines

  1. head     2.25;
  2. access   ;
  3. symbols  pre-merge:2.0;
  4. locks    joel:2.25; strict;
  5. comment  @ * @;
  6.  
  7.  
  8. 2.25
  9. date     89.12.28.12.47.01;  author joel;  state Exp;
  10. branches ;
  11. next     2.24;
  12.  
  13. 2.24
  14. date     89.12.27.19.05.49;  author joel;  state Exp;
  15. branches ;
  16. next     2.23;
  17.  
  18. 2.23
  19. date     89.12.14.10.08.39;  author joel;  state Exp;
  20. branches ;
  21. next     2.22;
  22.  
  23. 2.22
  24. date     89.12.14.09.48.33;  author joel;  state Exp;
  25. branches ;
  26. next     2.21;
  27.  
  28. 2.21
  29. date     89.12.14.09.34.11;  author joel;  state Exp;
  30. branches ;
  31. next     2.20;
  32.  
  33. 2.20
  34. date     89.12.12.17.32.04;  author joel;  state Exp;
  35. branches ;
  36. next     2.19;
  37.  
  38. 2.19
  39. date     89.12.07.16.37.42;  author joel;  state Exp;
  40. branches ;
  41. next     2.18;
  42.  
  43. 2.18
  44. date     89.11.21.08.55.55;  author joel;  state Exp;
  45. branches ;
  46. next     2.17;
  47.  
  48. 2.17
  49. date     89.11.02.10.48.10;  author joel;  state Exp;
  50. branches ;
  51. next     2.16;
  52.  
  53. 2.16
  54. date     89.10.25.14.57.24;  author joel;  state Exp;
  55. branches ;
  56. next     2.15;
  57.  
  58. 2.15
  59. date     89.10.24.09.48.33;  author joel;  state Exp;
  60. branches ;
  61. next     2.14;
  62.  
  63. 2.14
  64. date     89.10.06.15.15.53;  author joel;  state Exp;
  65. branches ;
  66. next     2.13;
  67.  
  68. 2.13
  69. date     89.09.28.15.25.28;  author joel;  state Exp;
  70. branches ;
  71. next     2.12;
  72.  
  73. 2.12
  74. date     89.06.23.14.14.16;  author joel;  state Exp;
  75. branches ;
  76. next     2.11;
  77.  
  78. 2.11
  79. date     89.05.17.11.06.43;  author joel;  state Exp;
  80. branches ;
  81. next     2.10;
  82.  
  83. 2.10
  84. date     89.05.16.21.00.10;  author joel;  state Exp;
  85. branches ;
  86. next     2.9;
  87.  
  88. 2.9
  89. date     89.05.16.12.07.19;  author joel;  state Exp;
  90. branches ;
  91. next     2.8;
  92.  
  93. 2.8
  94. date     89.05.16.11.44.41;  author joel;  state Exp;
  95. branches ;
  96. next     2.7;
  97.  
  98. 2.7
  99. date     89.05.12.12.21.34;  author joel;  state Exp;
  100. branches ;
  101. next     2.6;
  102.  
  103. 2.6
  104. date     89.05.11.17.41.55;  author joel;  state Exp;
  105. branches ;
  106. next     2.5;
  107.  
  108. 2.5
  109. date     89.05.11.16.45.23;  author joel;  state Exp;
  110. branches ;
  111. next     2.4;
  112.  
  113. 2.4
  114. date     89.05.08.18.38.02;  author joel;  state Exp;
  115. branches ;
  116. next     2.3;
  117.  
  118. 2.3
  119. date     89.05.04.13.44.16;  author joel;  state Exp;
  120. branches ;
  121. next     2.2;
  122.  
  123. 2.2
  124. date     89.05.03.14.18.29;  author joel;  state Exp;
  125. branches ;
  126. next     2.1;
  127.  
  128. 2.1
  129. date     89.04.18.14.15.47;  author joel;  state Exp;
  130. branches ;
  131. next     2.0;
  132.  
  133. 2.0
  134. date     89.02.21.14.37.02;  author erik;  state Exp;
  135. branches ;
  136. next     1.6;
  137.  
  138. 1.6
  139. date     89.02.21.14.37.02;  author joel;  state Exp;
  140. branches ;
  141. next     1.5;
  142.  
  143. 1.5
  144. date     89.01.31.17.08.21;  author joel;  state Exp;
  145. branches ;
  146. next     1.4;
  147.  
  148. 1.4
  149. date     88.11.26.16.21.59;  author joel;  state Exp;
  150. branches ;
  151. next     1.3;
  152.  
  153. 1.3
  154. date     88.10.13.14.01.41;  author todd;  state Exp;
  155. branches ;
  156. next     1.2;
  157.  
  158. 1.2
  159. date     88.07.27.09.56.40;  author joel;  state Exp;
  160. branches ;
  161. next     1.1;
  162.  
  163. 1.1
  164. date     88.06.20.21.41.02;  author joel;  state Exp;
  165. branches ;
  166. next     ;
  167.  
  168.  
  169. desc
  170. @@
  171.  
  172.  
  173. 2.25
  174. log
  175. @Make -labels option pay attention to which tests are specified
  176. @
  177. text
  178. @/*****************************************************************************
  179. Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
  180.  
  181.                         All Rights Reserved
  182.  
  183. Permission to use, copy, modify, and distribute this software and its 
  184. documentation for any purpose and without fee is hereby granted, 
  185. provided that the above copyright notice appear in all copies and that
  186. both that copyright notice and this permission notice appear in 
  187. supporting documentation, and that the name of Digital not be
  188. used in advertising or publicity pertaining to distribution of the
  189. software without specific, written prior permission.  
  190.  
  191. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  192. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  193. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  194. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  195. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  196. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  197. SOFTWARE.
  198.  
  199. ******************************************************************************/
  200.  
  201. #include <stdio.h>
  202. #include <ctype.h>
  203. #ifndef VMS
  204. #include <X11/Xatom.h>
  205. #include <X11/Xos.h>
  206. #else
  207. #include <decw$include/Xatom.h>
  208. #endif
  209. #include "x11perf.h"
  210.  
  211. /* Only for working on ``fake'' servers, for hardware that doesn't exist */
  212. static Bool     drawToFakeServer = False;
  213. static Pixmap   tileToQuery     = None;
  214.  
  215.  
  216. static Bool     labels        = False;
  217. static Bool     xorMode        = False;
  218. static Bool     bothModes       = False;
  219. static int      repeat        = 5;
  220. static int    seconds        = 5;
  221.  
  222. static Window   status;     /* Status window and GC */
  223. static GC       tgc;
  224.  
  225. static double syncTime = 0.0;
  226.  
  227. static int saveargc;
  228. static char **saveargv;
  229.  
  230. static char *foreground = NULL;
  231. static char *background = NULL;
  232.  
  233. static int  fixedReps = 0;
  234.  
  235. static Bool *doit;
  236.  
  237. static XRectangle ws[] = {  /* Clip rectangles */
  238.     {195, 195, 120, 120},
  239.     { 45, 145, 120, 120},
  240.     {345, 245, 120, 120}
  241.  
  242. };
  243. #define MAXCLIP     (sizeof(ws) / sizeof(ws[0]))
  244. static Window clipWindows[MAXCLIP];
  245.  
  246. /************************************************
  247. *        time related stuff            *
  248. ************************************************/
  249.  
  250. #ifdef VMS
  251.  
  252. typedef struct _vms_time {
  253.     unsigned long low;
  254.     unsigned long high;
  255. }vms_time;
  256.  
  257. struct timeval {
  258.     long tv_sec;        /* seconds since Jan. 1, 1970 */
  259.     long tv_usec;  /* and microseconds */
  260. };
  261.  
  262. struct timezone {
  263.     int  tz_minuteswest;     /* of Greenwich */
  264.     int  tz_dsttime;    /* type of dst correction to apply */
  265. };
  266.  
  267.  
  268. static int firsttime = True;
  269. static vms_time basetime;
  270.  
  271. int gettimeofday(tp, tzp)
  272.     struct timeval *tp;
  273.     struct timezone *tzp;
  274. {
  275.     vms_time current_time, resultant;
  276.     unsigned long mumble, foo;
  277.     int status;
  278.  
  279.     if (firsttime) {
  280.         sys$gettim(&basetime);
  281.         firsttime = False;
  282.     }
  283.     sys$gettim(¤t_time);
  284.     resultant.high = current_time.high - basetime.high;
  285.     resultant.low = current_time.low - basetime.low;
  286.     if (current_time.low < basetime.low) {
  287.         resultant.high -= 1;
  288.     }
  289.     status = lib$ediv( &(10000000), &resultant, &tp->tv_sec, &tp->tv_usec);
  290.     tp->tv_usec /= 10;
  291.     return 0;
  292. }
  293.  
  294. #endif
  295.  
  296. static struct  timeval start;
  297.  
  298. void PrintTime()
  299. {
  300.     time_t t;
  301.  
  302.     t = time((long *)NULL);
  303.     printf("%s\n", ctime(&t));
  304. }
  305.  
  306. void InitTimes ()
  307. {
  308.     struct timezone foo;
  309.     gettimeofday(&start, &foo);
  310. }
  311.  
  312. double ElapsedTime(correction)
  313.     double correction;
  314. {
  315.     struct timeval stop;
  316.     struct timezone foo;
  317.     
  318.     gettimeofday(&stop, &foo);
  319.     if (stop.tv_usec < start.tv_usec) {
  320.         stop.tv_usec += 1000000;
  321.     stop.tv_sec -= 1;
  322.     }
  323.     return  (double)(stop.tv_usec - start.tv_usec) +
  324.             (1000000.0 * (double)(stop.tv_sec - start.tv_sec)) - correction;
  325. }
  326.  
  327. double RoundTo3Digits(d)
  328.     double d;
  329. {
  330.     /* It's kind of silly to print out things like ``193658.4/sec'' so just
  331.        junk all but 3 most significant digits. */
  332.  
  333.     double exponent;
  334.  
  335.     exponent = 1.0;
  336.     if (d >= 1000.0) {
  337.     do {
  338.         exponent *= 10.0;
  339.     } while (d/exponent >= 1000.0);
  340.     d = (double)((int) (d/exponent + 0.5));
  341.     d *= exponent;
  342.     } else {
  343.     while (d*exponent < 100.0) {
  344.         exponent *= 10.0;
  345.     }
  346.     d = (double)((int) (d*exponent + 0.5));
  347.     d /= exponent;
  348.     }
  349.     return d;
  350. }
  351.  
  352.  
  353. void ReportTimes(usecs, n, str, average)
  354.     double  usecs;
  355.     int     n;
  356.     char    *str;
  357. {
  358.     double msecsperobj, objspersec;
  359.  
  360.     msecsperobj = usecs / (1000.0 * (double)n);
  361.     objspersec = (double) n * 1000000.0 / usecs;
  362.  
  363.     /* Round obj/sec to 3 significant digits.  Leave msec untouched, to allow
  364.     averaging results from several repetitions. */
  365.     objspersec =  RoundTo3Digits(objspersec);
  366.  
  367.     if (average) {
  368.     printf("%6d trep @@ %7.4f msec (%6.1f/sec): %s\n", 
  369.         n, msecsperobj, objspersec, str);
  370.     } else {
  371.     printf("%6d reps @@ %7.4f msec (%6.1f/sec): %s\n", 
  372.         n, msecsperobj, objspersec, str);
  373.     }
  374. }
  375.  
  376.  
  377.  
  378. /************************************************
  379. *        Generic X stuff            *
  380. ************************************************/
  381.  
  382. static char *program_name;
  383. void usage();
  384.  
  385. /*
  386.  * Get_Display_Name (argc, argv) Look for -display, -d, or host:dpy (obselete)
  387.  * If found, remove it from command line.  Don't go past a lone -.
  388.  */
  389. char *Get_Display_Name(pargc, argv)
  390.     int     *pargc;  /* MODIFIED */
  391.     char    **argv; /* MODIFIED */
  392. {
  393.     int     argc = *pargc;
  394.     char    **pargv = argv+1;
  395.     char    *displayname = NULL;
  396.     int     i;
  397.  
  398.     for (i = 1; i != argc; i++) {
  399.     char *arg = argv[i];
  400.  
  401.     if (!strcmp (arg, "-display") || !strcmp (arg, "-d")) {
  402.         if (++i >= argc) usage ();
  403.  
  404.         displayname = argv[i];
  405.         *pargc -= 2;
  406.         continue;
  407.     }
  408.     if (!strcmp(arg,"-")) {
  409.         while (i<argc)  *pargv++ = argv[i++];
  410.         break;
  411.     }
  412.     *pargv++ = arg;
  413.     }
  414.  
  415.     *pargv = NULL;
  416.     return (displayname);
  417. }
  418.  
  419.  
  420. /*
  421.  * Open_Display: Routine to open a display with correct error handling.
  422.  */
  423. Display *Open_Display(display_name)
  424.     char *display_name;
  425. {
  426.     Display *d;
  427.  
  428.     d = XOpenDisplay(display_name);
  429.     if (d == NULL) {
  430.     fprintf (stderr, "%s:  unable to open display '%s'\n",
  431.          program_name, XDisplayName (display_name));
  432.     usage ();
  433.     /* doesn't return */
  434.     }
  435.  
  436.     return(d);
  437. }
  438.  
  439. /************************************************
  440. *        Performance stuff        *
  441. ************************************************/
  442.  
  443.  
  444. void usage()
  445. {
  446.     char    **cpp;
  447.     int     i = 0;
  448.     static char *help_message[] = {
  449. "where options include:",
  450. "    -display host:dpy        the X server to contact",
  451. "    -sync            do the tests in synchronous mode",
  452. "    -repeat <n>        do tests <n> times (default = 5)",
  453. "    -time <s>            do tests for <s> seconds each (default = 5)",
  454. /*"    -draw            draw after each test -- pmax only",*/
  455. "    -all            do all tests",
  456. "    -range <test1>[,<test2>]    like all, but do <test1> to <test2>",
  457. "    -labels            generate test labels for use by x11perffill",
  458. "    -fg            the foreground color to use",
  459. "    -bg                the background color to use",
  460. "    -xor            use GXxor mode to draw",
  461. "    -both            use both GXcopy and GXxor mode to draw",
  462. "    -reps <n>            fix the rep count (default = auto scale)",
  463. "    -subs <s0 s1 ...>        a list of the number of sub-windows to use",
  464. NULL};
  465.  
  466.     fflush(stdout);
  467.     fprintf(stderr, "usage: %s [-options ...]\n", program_name);
  468.     for (cpp = help_message; *cpp; cpp++) {
  469.     fprintf(stderr, "%s\n", *cpp);
  470.     }
  471.     while (test[i].option != NULL) {
  472.         fprintf(stderr, "    %-28s   %s\n",
  473.         test[i].option, test[i].label);
  474.         i++;
  475.     }
  476.     fprintf(stderr, "\n");
  477.     
  478.     /* Print out original command line as the above usage message is so long */
  479.     for (i = 0; i != saveargc; i++) {
  480.     fprintf(stderr, "%s ", saveargv[i]);
  481.     }
  482.     fprintf(stderr, "\n\n");
  483.     exit (1);
  484. }
  485.  
  486. void NullProc(xp, p)
  487.     XParms  xp;
  488.     Parms   p;
  489. {
  490. }
  491.  
  492. Bool NullInitProc(xp, p, reps)
  493.     XParms  xp;
  494.     Parms   p;
  495.     int reps;
  496. {
  497.     return reps;
  498. }
  499.  
  500.  
  501. void HardwareSync(xp)
  502.     XParms  xp;
  503. {
  504.     /*
  505.      * Some graphics hardware allows the server to claim it is done,
  506.      * while in reality the hardware is busily working away.  So fetch
  507.      * a pixel from the window that was drawn to, which should be
  508.      * enough to make the server wait for the graphics hardware.
  509.      */
  510.     XImage *image;
  511.  
  512.     image = XGetImage(xp->d, xp->w, WIDTH-1, HEIGHT-1, 1, 1, ~0, ZPixmap);
  513.     XDestroyImage(image);
  514. }
  515.  
  516. void DoHardwareSync(xp, p, reps)
  517.     XParms  xp;
  518.     Parms   p;
  519.     int     reps;
  520. {
  521.     int i;
  522.     
  523.     for (i = 0; i != reps; i++) {
  524.     HardwareSync(xp);
  525.     }
  526. }
  527.  
  528. static Test syncTest = {
  529.     "syncTime", "Internal test for finding how long HardwareSync takes",
  530.     NullInitProc, DoHardwareSync, NullProc, NullProc, NONXOR, 0,
  531.     {1}
  532. };
  533.  
  534.  
  535. static Window CreatePerfWindow(xp, x, y, width, height)
  536.     XParms  xp;
  537.     int     width, height, x, y;
  538. {
  539.     XSetWindowAttributes xswa;
  540.     Window w;
  541.     Screen *s;
  542.     int su;
  543.  
  544. /*
  545.     s = DefaultScreenOfDisplay(xp->d);
  546.     su = XDoesBackingStore(s);
  547.     printf("Backing store of screen returns %d\n", su);
  548.     su = XDoesSaveUnders(s);
  549.     printf("Save unders of screen returns %d\n", su);
  550.     su = XPlanesOfScreen(s);
  551.     printf("Planes of screen returns %d\n", su);
  552. */
  553.     xswa.override_redirect = True;
  554.     xswa.backing_store = False;
  555.     xswa.save_under = False;
  556.     w = XCreateSimpleWindow (xp->d, DefaultRootWindow (xp->d),
  557.     x, y, width, height, 1, xp->foreground, xp->background);
  558.     XChangeWindowAttributes (xp->d, w, 
  559.         CWOverrideRedirect | CWSaveUnder | CWBackingStore, &xswa);
  560.     XMapWindow (xp->d, w);
  561.     return w;
  562. }
  563.  
  564.  
  565. void CreateClipWindows(xp, clips)
  566.     XParms  xp;
  567.     int     clips;
  568. {
  569.     int j;
  570.     XWindowAttributes    xwa;
  571.  
  572.     (void) XGetWindowAttributes(xp->d, xp->w, &xwa);
  573.     if (clips > MAXCLIP) clips = MAXCLIP;
  574.     for (j = 0; j != clips; j++) {
  575.     clipWindows[j] = CreatePerfWindow(xp,
  576.         xwa.x + ws[j].x, xwa.y + ws[j].y, ws[j].width, ws[j].height);
  577.     }
  578. } /* CreateClipWindows */
  579.  
  580.  
  581. void DestroyClipWindows(xp, clips)
  582.     XParms  xp;
  583.     int     clips;
  584. {
  585.     int j;
  586.  
  587.     if (clips > MAXCLIP) clips = MAXCLIP;
  588.     for (j = 0; j != clips; j++) {
  589.     XDestroyWindow(xp->d, clipWindows[j]);
  590.     }
  591. } /* DestroyClipWindows */
  592.  
  593.  
  594. double DoTest(xp, test, reps)
  595.     XParms  xp;
  596.     Test    *test;
  597.     int     reps;
  598. {
  599.     double  time;
  600.     int     ret_width, ret_height;
  601.  
  602.     HardwareSync (xp);
  603.     InitTimes ();
  604.     (*test->proc) (xp, &test->parms, reps);
  605.     HardwareSync(xp);
  606.  
  607.     time = ElapsedTime(syncTime);
  608.     if (drawToFakeServer)
  609.         XQueryBestSize(xp->d, TileShape, tileToQuery,
  610.                32, 32, &ret_width, &ret_height);
  611.     (*test->passCleanup) (xp, &test->parms);
  612.     return time;
  613. }
  614.  
  615.  
  616. int CalibrateTest(xp, test, seconds, usecperobj)
  617.     XParms  xp;
  618.     Test    *test;
  619.     int     seconds;
  620.     double  *usecperobj;
  621. {
  622. #define goal    2500000.0   /* Try to get up to 2.5 seconds            */
  623. #define enough  2000000.0   /* But settle for 2.0 seconds            */
  624. #define tick      10000.0   /* Assume clock not faster than .01 seconds     */
  625.  
  626.     double  usecs;
  627.     int     reps, didreps;  /* Reps desired, reps performed            */
  628.     int     exponent;
  629.  
  630.     /* Attempt to get an idea how long each rep lasts by getting enough
  631.        reps to last more tan enough.  Then scale that up to the number of
  632.        seconds desired.
  633.  
  634.        If init call to test ever fails, return False and test will be skipped.
  635.     */
  636.  
  637.     if (fixedReps != 0) {
  638.     return fixedReps;
  639.     }
  640.     reps = 1;
  641.     for (;;) {
  642.     XDestroySubwindows(xp->d, xp->w);
  643.     XClearWindow(xp->d, xp->w);
  644.     didreps = (*test->init) (xp, &test->parms, reps);
  645.     if (didreps == 0) {
  646.         return 0;
  647.     }
  648.     /* Create clip windows if requested */
  649.     CreateClipWindows(xp, test->clips);
  650.     HardwareSync(xp);
  651.     InitTimes();
  652.     (*test->proc) (xp, &test->parms, reps);
  653.     HardwareSync(xp);
  654.     usecs = ElapsedTime(syncTime);
  655.     (*test->passCleanup) (xp, &test->parms);
  656.     (*test->cleanup) (xp, &test->parms);
  657.     DestroyClipWindows(xp, test->clips);
  658.  
  659.     if (didreps != reps) {
  660.         /* The test can't do the number of reps as we asked for.  
  661.            Give up */
  662.         *usecperobj = 
  663.         usecs / (double)(didreps * test->parms.objects);
  664.         return didreps;
  665.     }
  666.     /* Did we go long enough? */
  667.     if (usecs >= enough) break;
  668.  
  669.     /* Don't let too short a clock make new reps wildly high */
  670.     if (usecs < tick) usecs = tick;
  671.  
  672.     /* Try to get up to goal seconds. */
  673.     reps = (int) (goal * (double)reps / usecs) + 1;
  674.     }
  675.  
  676.     *usecperobj = usecs / (double) (reps * test->parms.objects);
  677.     reps = (int) ((double)seconds * 1000000.0 * (double)reps / usecs) + 1;
  678.  
  679.     /* Now round reps up to 1 digit accuracy, so we don't get stupid-looking
  680.        numbers of repetitions. */
  681.     reps--;
  682.     exponent = 1;
  683.     while (reps > 9) {
  684.     reps /= 10;
  685.     exponent *= 10;
  686.     }
  687.     reps = (reps + 1) * exponent;
  688.     return reps;
  689. } /* CalibrateTest */
  690.  
  691.  
  692. void CreatePerfGCs(xp, func)
  693.     XParms  xp;
  694.     int     func;
  695. {
  696.     XGCValues gcv;
  697.  
  698.     gcv.graphics_exposures = False;
  699.  
  700.     if (func == GXxor) {
  701.     gcv.function = GXxor;
  702.     gcv.foreground = xp->background ^ xp->foreground;
  703.     gcv.background = xp->background;
  704.         xp->fggc = XCreateGC(xp->d, xp->w, 
  705.         GCForeground | GCBackground | GCGraphicsExposures | GCFunction,
  706.         &gcv);
  707.         xp->bggc = XCreateGC(xp->d, xp->w, 
  708.         GCForeground | GCBackground | GCGraphicsExposures | GCFunction,
  709.         &gcv);
  710.     } else {
  711.     gcv.foreground = xp->foreground;
  712.     gcv.background = xp->background;
  713.     xp->fggc = XCreateGC(xp->d, xp->w, 
  714.         GCForeground | GCBackground | GCGraphicsExposures, &gcv);
  715.     gcv.foreground = xp->background;
  716.     gcv.background = xp->foreground;
  717.     xp->bggc = XCreateGC(xp->d, xp->w, 
  718.         GCForeground | GCBackground | GCGraphicsExposures, &gcv);
  719.     }
  720. }
  721.  
  722. void DestroyPerfGCs(xp)
  723.     XParms(xp);
  724. {
  725.     XFreeGC(xp->d, xp->fggc);
  726.     XFreeGC(xp->d, xp->bggc);
  727. }
  728.  
  729. int AllocateColor(display, name, pixel)
  730.     Display     *display;
  731.     char    *name;
  732.     int        pixel;
  733. {
  734.     XColor      color;
  735.     Colormap    cmap;
  736.  
  737.     if (name != NULL) {
  738.     cmap = XDefaultColormap(display, DefaultScreen(display));
  739.  
  740.     /* Try to parse color name */
  741.     if (XParseColor(display, cmap, name, &color)) {
  742.         if (XAllocColor(display, cmap, &color)) {
  743.         pixel = color.pixel;
  744.         } else {
  745.         (void) fprintf(stderr,
  746.             "Can't allocate colormap entry for color %s\n", name);
  747.         }
  748.     } else {
  749.         (void) fprintf(stderr, "Can't parse color name %s\n", name);
  750.     }
  751.     }
  752.     return pixel;
  753. } /* AllocateColor */
  754.  
  755.  
  756. void DisplayStatus(d, message, test)
  757.     Display *d;
  758.     char    *message;
  759.     char    *test;
  760. {
  761.     char    s[500];
  762.  
  763.     XClearWindow(d, status);
  764.     sprintf(s, "%s %s", message, test);
  765.     /* We should really look at the height, descent of the font, etc. but
  766.        who cares.  This works. */
  767.     XDrawString(d, status, tgc, 10, 13, s, strlen(s));
  768. }
  769.  
  770.  
  771. void ProcessTest(xp, test, func, label)
  772.     XParms  xp;
  773.     Test    *test;
  774.     int     func;
  775.     char    *label;
  776. {
  777.     double  time, totalTime;
  778.     int     reps;
  779.     int     j;
  780.  
  781.     CreatePerfGCs(xp, func);
  782.     DisplayStatus(xp->d, "Calibrating", label);
  783.     reps = CalibrateTest(xp, test, seconds, &time);
  784.     if (reps != 0) {
  785.     DisplayStatus(xp->d, "Testing", label);
  786.     XDestroySubwindows(xp->d, xp->w);
  787.     XClearWindow(xp->d, xp->w);
  788.     (void)(*test->init) (xp, &test->parms, reps);
  789.     /* Create clip windows if requested */
  790.     CreateClipWindows(xp, test->clips);
  791.  
  792.     totalTime = 0.0;
  793.     for (j = 0; j != repeat; j++) {
  794.         time = DoTest(xp, test, reps);
  795.         totalTime += time;
  796.         ReportTimes (time, reps * test->parms.objects,
  797.             label, False);
  798.     }
  799.     if (repeat > 1) {
  800.         ReportTimes(totalTime,
  801.         repeat * reps * test->parms.objects,
  802.         label, True);
  803.     }
  804.     (*test->cleanup) (xp, &test->parms);
  805.     DestroyClipWindows(xp, test->clips);
  806.     } else {
  807.     /* Test failed to initialize properly */
  808.     }
  809.     printf ("\n");
  810.     fflush(stdout);
  811.     DestroyPerfGCs(xp);
  812. } /* ProcessTest */
  813.  
  814.  
  815. main(argc, argv)
  816.     int argc;
  817.     char **argv;
  818.  
  819. {
  820.     int        i, j;
  821.     int        numTests;       /* Even though the linker knows, we don't. */
  822.     char    hostname[100];
  823.     char    *displayName;
  824.     XParmRec    xparms;
  825.     Bool    foundOne = False;
  826.     Bool    synchronous = False;
  827.     XGCValues    tgcv;
  828.     int        screen;
  829.  
  830.     /* ScreenSaver state */
  831.     int ssTimeout, ssInterval, ssPreferBlanking, ssAllowExposures;
  832.  
  833.     /* Save away argv, argc, for usage to print out */
  834.     saveargc = argc;
  835.     saveargv = (char **) malloc(argc * sizeof(char *));
  836.     for (i = 0; i != argc; i++) {
  837.     saveargv[i] = argv[i];
  838.     }
  839.  
  840.     xparms.pack = False;
  841.  
  842.     /* Count number of tests */
  843.     ForEachTest(numTests);
  844.     doit = (Bool *)calloc(numTests, sizeof(Bool));
  845.  
  846.     /* Parse arguments */
  847.     program_name = argv[0];
  848.     displayName = Get_Display_Name (&argc, argv);
  849.     for (i = 1; i != argc; i++) {
  850.     if (strcmp (argv[i], "-all") == 0) {
  851.         ForEachTest (j)
  852.         doit[j] = True;
  853.         foundOne = True;
  854.     } else if (strcmp (argv[i], "-labels") == 0) {
  855.         labels = True;
  856.     } else if (strcmp(argv[i], "-range") == 0) {
  857.         char *cp1;
  858.         char *cp2;
  859.         
  860.         if (argc <= ++i)
  861.         usage();
  862.         cp1 = argv[i];
  863.         if (*cp1 == '-')
  864.         *cp1++;
  865.         for (cp2 = cp1; *cp2 != '\0' && *cp2 != ','; cp2++) {};
  866.         if (*cp2 == ',') {
  867.         *cp2++ = '\0';
  868.         if (*cp2 == '-')
  869.             *cp2++;
  870.         } else {
  871.         cp2 = "-";
  872.         }
  873.         ForEachTest (j) {
  874.         if (strcmp (cp1, (test[j].option) + 1) == 0) {
  875.             int k = j;
  876.             do {
  877.             doit[k] = True;
  878.             } while (strcmp(cp2, (test[k].option + 1)) != 0 &&
  879.                  test[++k].option != NULL);
  880.             if (*cp2 != '-' && test[k].option == NULL)
  881.             usage();
  882.             break;
  883.         }
  884.         }
  885.         if (test[j].option == NULL)
  886.         usage();
  887.         foundOne = True;
  888.     } else if (strcmp (argv[i], "-sync") == 0) {
  889.         synchronous = True;
  890.     } else if (strcmp(argv[i], "-pack") == 0) {
  891.         xparms.pack = True;
  892.     } else if (strcmp (argv[i], "-draw") == 0) {
  893.         drawToFakeServer = True;
  894.     } else if (strcmp (argv[i], "-repeat") == 0) {
  895.         if (argc <= i)
  896.         usage ();
  897.         repeat = atoi (argv[++i]);
  898.         if (repeat <= 0)
  899.            usage ();
  900.     } else if (strcmp (argv[i], "-time") == 0) {
  901.         if (argc <= i)
  902.         usage ();
  903.         seconds = atoi (argv[++i]);
  904.         if (seconds <= 0)
  905.            usage ();
  906.     } else if (strcmp(argv[i], "-fg") == 0) {
  907.         if (argc <= i)
  908.         usage ();
  909.         i++;
  910.         foreground = argv[i];
  911.         } else if (strcmp(argv[i], "-bg") == 0) {
  912.         if (argc <= i)
  913.         usage ();
  914.         i++;
  915.         background = argv[i];
  916.     } else if (strcmp(argv[i], "-xor") == 0) {
  917.         xorMode = True;
  918.     } else if (strcmp(argv[i], "-both") == 0) {
  919.         bothModes = True;
  920.     } else if (strcmp(argv[i], "-reps") == 0) {
  921.         if (argc <= i)
  922.         usage ();
  923.         fixedReps = atoi (argv[++i]);
  924.         if (fixedReps <= 0)
  925.         usage ();
  926.     } else if (strcmp(argv[i], "-subs") == 0) {
  927.         int    j = 0;
  928.         if (argc <= i)
  929.         usage ();
  930.         i++;
  931.         while (i < argc && isdigit (argv[i][0]))
  932.         {
  933.         if (subs[j] != 0) {
  934.             subs[j] = atoi (argv[i++]);
  935.             j++;
  936.         }
  937.         i++;
  938.         }
  939.         --i;
  940.     } else {
  941.         ForEachTest (j) {
  942.         if (strcmp (argv[i], test[j].option) == 0) {
  943.             doit[j] = True;
  944.             goto LegalOption;
  945.         }
  946.         }
  947.         usage ();
  948.     LegalOption: 
  949.         foundOne = True;
  950.     }
  951.     }
  952.  
  953.     if (labels) {
  954.     /* Just print out list of tests for use with .sh programs that
  955.        assemble data from different x11perf runs into a nice format */
  956.     ForEachTest (i) {
  957.         int child;
  958.         if (doit[i]) {
  959.         switch (test[i].testType) {
  960.             case NONXOR:
  961.             printf ("%s\n", test[i].label);
  962.             break;
  963.     
  964.             case XOR:
  965.             if (!xorMode || bothModes) {
  966.                 printf ("%s\n", test[i].label);
  967.             }
  968.             if (xorMode || bothModes) {
  969.                 printf("(XOR) %s\n", test[i].label);
  970.             }
  971.             break;
  972.             
  973.             case WINDOW:
  974.             for (child = 0; subs[child] != 0; child++) {
  975.                 printf ("%s (%d kids)\n",
  976.                 test[i].label, subs[child]);
  977.             }
  978.             break;
  979.         } /* switch */
  980.         }
  981.     }
  982.     exit(0);
  983.     }
  984.  
  985.     if (!foundOne)
  986.     usage ();
  987.     xparms.d = Open_Display (displayName);
  988.     printf("x11perf - X11 performance program, version 1.2\n");
  989. #ifndef VMS
  990.     gethostname (hostname, 100);
  991.     printf ("%s server on %s\nfrom %s\n",
  992.         ServerVendor (xparms.d), DisplayString (xparms.d), hostname);
  993. #else
  994.     printf ("%s server on %s\n",
  995.         ServerVendor (xparms.d), DisplayString (xparms.d));
  996. #endif
  997.     screen = DefaultScreen (xparms.d);
  998.     PrintTime ();
  999.  
  1000.     /* Force screen out of screen-saver mode, grab current data, and set
  1001.        time to blank to 8 hours.  This finesses various problems if you
  1002.        try to turn it off completely.  As long as the tests run to 
  1003.        completion, the old screen-saver values are restored. */
  1004.     XForceScreenSaver(xparms.d, ScreenSaverReset);
  1005.     XGetScreenSaver(xparms.d, &ssTimeout, &ssInterval, &ssPreferBlanking,
  1006.     &ssAllowExposures);
  1007.     XSetScreenSaver(xparms.d, 8 * 3600, ssInterval, ssPreferBlanking,
  1008.     ssAllowExposures);
  1009.  
  1010.     if (drawToFakeServer) {
  1011.         tileToQuery =
  1012.         XCreatePixmap(xparms.d, DefaultRootWindow (xparms.d), 32, 32, 1);
  1013.     }
  1014.  
  1015.  
  1016.     xparms.foreground =
  1017.     AllocateColor(xparms.d, foreground, BlackPixel(xparms.d, screen));
  1018.     xparms.background =
  1019.     AllocateColor(xparms.d, background, WhitePixel(xparms.d, screen));
  1020.     xparms.w = CreatePerfWindow(&xparms, 2, 2, WIDTH, HEIGHT);
  1021.     status = CreatePerfWindow(&xparms, 2, HEIGHT+5, WIDTH, 20);
  1022.     tgcv.foreground = BlackPixel(xparms.d, screen);
  1023.     tgcv.background = WhitePixel(xparms.d, screen);
  1024.     tgc = XCreateGC(xparms.d, status, GCForeground | GCBackground, &tgcv);
  1025.    
  1026.  
  1027.     if (synchronous)
  1028.     XSynchronize (xparms.d, True);
  1029.  
  1030.     /* Get mouse pointer out of the way of the performance window.  On
  1031.        software cursor machines it will slow graphics performance.  On
  1032.        all current MIT-derived servers it will slow window 
  1033.        creation/configuration performance. */
  1034.     XWarpPointer(xparms.d, None, status, 0, 0, 0, 0, WIDTH, 20);
  1035.  
  1036.     /* Figure out how long to call HardwareSync, so we can adjust for that
  1037.        in our total elapsed time */
  1038.     (void) CalibrateTest(&xparms, &syncTest, 1, &syncTime);
  1039.     printf("Sync time adjustment is %6.4f msecs.\n\n", syncTime/1000);
  1040.  
  1041.     ForEachTest (i) {
  1042.     int child;
  1043.     char label[200];
  1044.  
  1045.     if (doit[i]) {
  1046.         switch (test[i].testType) {
  1047.             case NONXOR:
  1048.             /* Simplest...just run it once */
  1049.             strcpy (label, test[i].label);
  1050.             ProcessTest(&xparms, &test[i], GXcopy, label);
  1051.             break;
  1052.  
  1053.         case XOR:
  1054.             /* Run it once or twice */
  1055.             if (!xorMode || bothModes) {
  1056.             /* Copy mode */
  1057.             strcpy (label, test[i].label);
  1058.             ProcessTest(&xparms, &test[i], GXcopy, label);
  1059.             }
  1060.             if (xorMode || bothModes) {
  1061.             /* Xor mode */
  1062.             sprintf(label, "(XOR) %s", test[i].label);
  1063.             ProcessTest(&xparms, &test[i], GXxor, label);
  1064.             }
  1065.             break;
  1066.         
  1067.         case WINDOW:
  1068.             /* Loop through number of children array */
  1069.             for (child = 0; subs[child] != 0; child++) {
  1070.             test[i].parms.objects = subs[child];
  1071.             sprintf(label, "%s (%d kids)",
  1072.                 test[i].label, test[i].parms.objects);
  1073.             ProcessTest(&xparms, &test[i], GXcopy, label);
  1074.             }
  1075.             break;
  1076.         } /* switch */
  1077.     } /* if doit */
  1078.     } /* ForEachTest */
  1079.  
  1080.     XDestroyWindow(xparms.d, xparms.w);
  1081.  
  1082.     /* Restore ScreenSaver to original state. */
  1083.     XSetScreenSaver(xparms.d, ssTimeout, ssInterval, ssPreferBlanking,
  1084.     ssAllowExposures);
  1085. }
  1086.  
  1087. @
  1088.  
  1089.  
  1090. 2.24
  1091. log
  1092. @Don't use index function; it doesn't exist on VMS
  1093. @
  1094. text
  1095. @d280 1
  1096. a280 1
  1097. "    -labels            generate test labels for use by fillblanks.sh",
  1098. d781 3
  1099. a783 7
  1100.         switch (test[i].testType) {
  1101.             case NONXOR:
  1102.             printf ("%s\n", test[i].label);
  1103.             break;
  1104.  
  1105.         case XOR:
  1106.             if (!xorMode || bothModes) {
  1107. d785 19
  1108. a803 12
  1109.             }
  1110.             if (xorMode || bothModes) {
  1111.             printf("(XOR) %s\n", test[i].label);
  1112.             }
  1113.             break;
  1114.         
  1115.         case WINDOW:
  1116.             for (child = 0; subs[child] != 0; child++) {
  1117.             printf ("%s (%d kids)\n", test[i].label, subs[child]);
  1118.             }
  1119.             break;
  1120.         } /* switch */
  1121. @
  1122.  
  1123.  
  1124. 2.23
  1125. log
  1126. @Fix a couple places where'd I'd missed in the reps as explicit parameter change
  1127. @
  1128. text
  1129. @d688 2
  1130. a689 1
  1131.         if ((cp2 = index(cp1, ',')) != NULL) {
  1132. @
  1133.  
  1134.  
  1135. 2.22
  1136. log
  1137. @Added -pack option (see do_rects.c)
  1138. @
  1139. text
  1140. @d315 1
  1141. a315 1
  1142. Bool NullInitProc(xp, p)
  1143. d318 1
  1144. d320 1
  1145. a320 1
  1146.     return True;
  1147. d354 1
  1148. a354 1
  1149.     {5000, 1}
  1150. @
  1151.  
  1152.  
  1153. 2.21
  1154. log
  1155. @Changed positions of clip rectangles to match seg100 better
  1156. @
  1157. text
  1158. @d662 2
  1159. d709 1
  1160. a709 1
  1161.     } else if (strcmp (argv[i], "-sync") == 0) {
  1162. d711 2
  1163. @
  1164.  
  1165.  
  1166. 2.20
  1167. log
  1168. @Changed -start option to -range option
  1169. Changed to version 1.2
  1170. @
  1171. text
  1172. @d61 3
  1173. a63 3
  1174.     {240, 240, 120, 120},
  1175.     { 40, 190, 120, 120},
  1176.     {440, 290, 120, 120}
  1177. @
  1178.  
  1179.  
  1180. 2.19
  1181. log
  1182. @Changed interface to p->reps
  1183. Added -both option
  1184. @
  1185. text
  1186. @d279 1
  1187. a279 1
  1188. "    -start <test>        like all, but start at <test>",
  1189. d676 26
  1190. a701 9
  1191.     } else if (strcmp(argv[i], "-start") == 0) {
  1192.         if (argc <= i)
  1193.         usage();
  1194.         i++;
  1195.         ForEachTest (j) {
  1196.         if (strcmp (argv[i], test[j].option) == 0) {
  1197.         int k;
  1198.         for (k = j; test[k].option != NULL; k++) {
  1199.             doit[k] = True;
  1200. a702 1
  1201.         break;
  1202. d704 3
  1203. a706 4
  1204.         }
  1205.         if (test[j].option == NULL)
  1206.         usage();
  1207.         foundOne = True;
  1208. d802 1
  1209. a802 1
  1210.     printf("x11perf - X11 performance program, version 1.1\n");
  1211. @
  1212.  
  1213.  
  1214. 2.18
  1215. log
  1216. @Make it easier to check out effects of backing store on performance.
  1217. @
  1218. text
  1219. @d34 3
  1220. a36 4
  1221. static Bool drawToFakeServer = False;
  1222. static Pixmap tileToQuery = None;
  1223. static Bool labels = False;
  1224. static Bool xorMode = False;
  1225. d38 10
  1226. d284 1
  1227. d338 1
  1228. a338 1
  1229. void DoHardwareSync(xp, p)
  1230. d341 1
  1231. d345 1
  1232. a345 1
  1233.     for (i = 0; i != p->reps; i++) {
  1234. d352 1
  1235. a352 1
  1236.     NullInitProc, DoHardwareSync, NullProc, NullProc, False, 0,
  1237. d416 1
  1238. a416 1
  1239. double DoTest(xp, test, label)
  1240. d419 1
  1241. a419 1
  1242.     char    *label;
  1243. d426 1
  1244. a426 1
  1245.     (*test->proc) (xp, &test->parms);
  1246. d438 1
  1247. a438 1
  1248. Bool CalibrateTest(xp, test, seconds, usecperobj)
  1249. d449 2
  1250. a450 1
  1251.     int     reps, exponent;
  1252. d459 2
  1253. a460 3
  1254.     if (fixedReps) {
  1255.     test->parms.reps = fixedReps;
  1256.     return True;
  1257. a463 1
  1258.     test->parms.reps = reps;
  1259. d466 3
  1260. a468 2
  1261.     if (! ((*test->init) (xp, &test->parms))) {
  1262.         return False;
  1263. d474 1
  1264. a474 1
  1265.     (*test->proc) (xp, &test->parms);
  1266. d481 1
  1267. a481 1
  1268.     if (reps != test->parms.reps) {
  1269. d485 2
  1270. a486 2
  1271.         usecs / (double)(test->parms.reps * test->parms.objects);
  1272.         return True;
  1273. d510 1
  1274. a510 2
  1275.     test->parms.reps = reps;
  1276.     return True;
  1277. d514 1
  1278. a514 1
  1279. void CreatePerfGCs(xp)
  1280. d516 1
  1281. d522 1
  1282. a522 1
  1283.     if (xorMode) {
  1284. d578 1
  1285. a578 1
  1286. void DisplayStatus(d, w, tgc, message, test)
  1287. a579 2
  1288.     Window  w;
  1289.     GC      tgc;
  1290. d585 1
  1291. a585 1
  1292.     XClearWindow(d, w);
  1293. d589 1
  1294. a589 1
  1295.     XDrawString(d, w, tgc, 10, 13, s, strlen(s));
  1296. d593 44
  1297. a646 2
  1298.     int        repeat = 5;
  1299.     int        seconds = 5;
  1300. a648 2
  1301.     Window      status;
  1302.     GC        tgc;        
  1303. d720 2
  1304. d760 20
  1305. a779 7
  1306.         if (test[i].children) {
  1307.         for (child = 0; subs[child] != 0; child++) {
  1308.             printf ("%s (%d kids)\n", test[i].label, subs[child]);
  1309.         }
  1310.         } else {
  1311.         printf ("%s\n", test[i].label);
  1312.         }
  1313. d841 3
  1314. d845 3
  1315. a847 14
  1316.         int     child = 0;
  1317.         char    label[100];
  1318.         int     reps = test[i].parms.reps;
  1319.         double  time, totalTime;
  1320.  
  1321.         CreatePerfGCs(&xparms);
  1322.         while (1) {
  1323.         if (test[i].children) {
  1324.             test[i].parms.objects = subs[child];
  1325.             if (test[i].parms.objects == 0)
  1326.             break;
  1327.             sprintf (label, "%s (%d kids)",
  1328.                 test[i].label, test[i].parms.objects);
  1329.         } else {
  1330. d849 2
  1331. a850 9
  1332.         }
  1333.         DisplayStatus(xparms.d, status, tgc, "Calibrating", label);
  1334.         if (CalibrateTest(&xparms, &test[i], seconds, &time)) {
  1335.             DisplayStatus(xparms.d, status, tgc, "Testing", label);
  1336.             XDestroySubwindows(xparms.d, xparms.w);
  1337.             XClearWindow(xparms.d, xparms.w);
  1338.             (void)(*test[i].init) (&xparms, &test[i].parms);
  1339.             /* Create clip windows if requested */
  1340.             CreateClipWindows(&xparms, test[i].clips);
  1341. d852 6
  1342. a857 7
  1343.             totalTime = 0.0;
  1344.             for (j = 0; j != repeat; j++) {
  1345.             time = DoTest(&xparms, &test[i], label);
  1346.             totalTime += time;
  1347.             ReportTimes (time, 
  1348.                 test[i].parms.reps * test[i].parms.objects,
  1349.                 label, False);
  1350. d859 4
  1351. a862 4
  1352.             if (repeat > 1) {
  1353.             ReportTimes(totalTime,
  1354.                 repeat * test[i].parms.reps * test[i].parms.objects,
  1355.                 label, True);
  1356. a863 8
  1357.             (*test[i].cleanup) (&xparms, &test[i].parms);
  1358.             DestroyClipWindows(&xparms, test[i].clips);
  1359.         } else {
  1360.             /* Test failed to initialize properly */
  1361.         }
  1362.         printf ("\n");
  1363.         fflush(stdout);
  1364.         if (!test[i].children)
  1365. d865 14
  1366. a878 5
  1367.         child++;
  1368.         }
  1369.         DestroyPerfGCs(&xparms);
  1370.     }
  1371.     }
  1372. @
  1373.  
  1374.  
  1375. 2.17
  1376. log
  1377. @Added (in comment) backing-store, for comparing how it affects performance
  1378. @
  1379. text
  1380. @d352 2
  1381. d355 9
  1382. d365 2
  1383. a366 1
  1384. /*  xswa.backing_store = Always;  See if backing store costs anything */
  1385. d369 2
  1386. a370 1
  1387.     XChangeWindowAttributes (xp->d, w, CWOverrideRedirect, &xswa);
  1388. @
  1389.  
  1390.  
  1391. 2.16
  1392. log
  1393. @Added -start option
  1394. @
  1395. text
  1396. @d354 1
  1397. @
  1398.  
  1399.  
  1400. 2.15
  1401. log
  1402. @*** empty log message ***
  1403. @
  1404. text
  1405. @d270 1
  1406. d613 17
  1407. a629 1
  1408.     } else if (strcmp (argv[i], "-sync") == 0) {
  1409. d808 1
  1410. @
  1411.  
  1412.  
  1413. 2.14
  1414. log
  1415. @Added generation of labels.
  1416. Added average timings for a test
  1417. @
  1418. text
  1419. @d270 1
  1420. a270 1
  1421. "    -labels            generate test labels for use by mungeall.sh",
  1422. @
  1423.  
  1424.  
  1425. 2.13
  1426. log
  1427. @Allow -reps n to specify number of iterations within a test
  1428. Allow -subs at end to specify list of number of windows
  1429. @
  1430. text
  1431. @d36 1
  1432. a36 1
  1433.  
  1434. d167 1
  1435. a167 1
  1436. void ReportTimes(usecs, n, str)
  1437. d181 7
  1438. a187 2
  1439.     printf("%6d reps @@ %7.4f msec (%6.1f/sec): %s\n", 
  1440.     n, msecsperobj, objspersec, str);
  1441. d270 1
  1442. d390 1
  1443. a390 1
  1444. DoTest(xp, test, label)
  1445. a403 1
  1446.     ReportTimes (time, test->parms.reps * test->parms.objects, label);
  1447. d408 1
  1448. d610 2
  1449. d672 17
  1450. d692 1
  1451. a692 1
  1452.     printf("x11perf - X11 performance program, version 1.0\n");
  1453. d695 1
  1454. a695 1
  1455.     printf ("%s server on %s from %s\n",
  1456. d750 1
  1457. a750 1
  1458.         double  junk;
  1459. d764 1
  1460. a764 1
  1461.         if (CalibrateTest(&xparms, &test[i], seconds, &junk)) {
  1462. d772 13
  1463. a784 2
  1464.             for (j = 0; j != repeat; j++)
  1465.             DoTest (&xparms, &test[i], label);
  1466. @
  1467.  
  1468.  
  1469. 2.12
  1470. log
  1471. @Added ability to specify -xor for gcs
  1472. @
  1473. text
  1474. @d25 1
  1475. d47 2
  1476. d268 2
  1477. d426 4
  1478. d632 20
  1479. @
  1480.  
  1481.  
  1482. 2.11
  1483. log
  1484. @Fixed gcs to turn of graphics_exposures, which means we don't get zillions
  1485. of NoExpose events.
  1486. @
  1487. text
  1488. @d36 2
  1489. d264 1
  1490. d481 14
  1491. a494 3
  1492.     gcv.foreground = xp->background;
  1493.     gcv.background = xp->foreground;
  1494.     xp->bggc = XCreateGC(xp->d, xp->w, 
  1495. d496 3
  1496. a498 4
  1497.  
  1498.     gcv.foreground = xp->foreground;
  1499.     gcv.background = xp->background;
  1500.     xp->fggc = XCreateGC(xp->d, xp->w, 
  1501. d500 1
  1502. d621 2
  1503. @
  1504.  
  1505.  
  1506. 2.10
  1507. log
  1508. @Allow screens other than 0
  1509. Set up status window with BlackPixel and WhitePixel
  1510. @
  1511. text
  1512. @d476 2
  1513. d480 2
  1514. a481 1
  1515.     xp->bggc = XCreateGC(xp->d, xp->w, GCForeground | GCBackground , &gcv);
  1516. d485 2
  1517. a486 1
  1518.     xp->fggc = XCreateGC(xp->d, xp->w, GCForeground | GCBackground , &gcv);
  1519. @
  1520.  
  1521.  
  1522. 2.9
  1523. log
  1524. @XWarpPointer out of benchmark window
  1525. @
  1526. text
  1527. @d27 1
  1528. a27 1
  1529. #include <sys/time.h>
  1530. d258 1
  1531. a258 1
  1532. "    -draw            draw after each test -- pmax only",
  1533. d339 1
  1534. a339 1
  1535.     w = XCreateSimpleWindow (xp->d, RootWindow (xp->d, 0),
  1536. d438 2
  1537. a439 1
  1538.         /* The test can't do the number of reps as we asked for.  Give up */
  1539. d541 4
  1540. a544 4
  1541.     int     i, j;
  1542.     int     numTests;       /* Even though the linker knows, we don't. */
  1543.     char    hostname[100];
  1544.     char   *displayName;
  1545. d546 8
  1546. a553 6
  1547.     int     repeat = 5;
  1548.     int     seconds = 5;
  1549.     Bool    foundOne = False;
  1550.     Bool    synchronous = False;
  1551.     Window  status;
  1552.     GC      tgc;        
  1553. d618 1
  1554. d627 1
  1555. d631 3
  1556. a633 1
  1557.        time to blank to a suitable large number, like 3 hours. */
  1558. d637 1
  1559. a637 1
  1560.     XSetScreenSaver(xparms.d, 3 * 3600, ssInterval, ssPreferBlanking,
  1561. d642 1
  1562. a642 1
  1563.         XCreatePixmap(xparms.d, RootWindow (xparms.d, 0), 32, 32, 1);
  1564. d647 1
  1565. a647 1
  1566.     AllocateColor(xparms.d, foreground, BlackPixel(xparms.d, 0));
  1567. d649 1
  1568. a649 1
  1569.     AllocateColor(xparms.d, background, WhitePixel(xparms.d, 0));
  1570. d652 4
  1571. a655 2
  1572.     tgc = XCreateGC(xparms.d, status, 0, NULL);
  1573.     
  1574. d662 2
  1575. a663 2
  1576.        all MIT-derived servers it will slow window creation/configuration
  1577.        performance. */
  1578. @
  1579.  
  1580.  
  1581. 2.8
  1582. log
  1583. @Made CalibrateTest give up if it ever gets back a DIFFERENT number of reps than it asked for
  1584. @
  1585. text
  1586. @d553 1
  1587. a553 1
  1588.     int ssTimeout, ssIntervalReturn, ssPreferBlanking, ssAllowExposures;
  1589. d625 4
  1590. a628 2
  1591. /* ||| Doesn't seem to work so well.
  1592.     XGetScreenSaver(xparms.d, &ssTimeout, &ssIntervalReturn, &ssPreferBlanking,
  1593. d630 2
  1594. a631 3
  1595.     XForceScreenSaver(xparms.d, ScreenSaverReset);
  1596.     XSetScreenSaver(xparms.d, 0, 0, DefaultBlanking, DefaultExposures);
  1597. */
  1598. d651 6
  1599. d705 3
  1600. a707 2
  1601. /*
  1602.     XSetScreenSaver(xparms.d, ssTimeout, ssIntervalReturn, ssPreferBlanking,
  1603. a708 1
  1604. */
  1605. @
  1606.  
  1607.  
  1608. 2.7
  1609. log
  1610. @Calibrate calculates usecperobj a little better
  1611. @
  1612. text
  1613. @d309 1
  1614. a309 1
  1615.     image = XGetImage(xp->d, xp->w, 1, 1, 1, 1, ~0, ZPixmap);
  1616. d437 2
  1617. a438 2
  1618.     if (reps > test->parms.reps) {
  1619.         /* The test can't do as many reps as we asked for.  Give up */
  1620. @
  1621.  
  1622.  
  1623. 2.6
  1624. log
  1625. @Raise minimum calibration time to 2 seconds, just to get rid of cache
  1626. effects better, and get a more accurate handle.
  1627. @
  1628. text
  1629. @d439 2
  1630. a440 1
  1631.         *usecperobj =  usecs / (double)test->parms.reps;
  1632. d453 1
  1633. a453 1
  1634.     *usecperobj = usecs / (double)reps;
  1635. @
  1636.  
  1637.  
  1638. 2.5
  1639. log
  1640. @Parameters to all routines now (xp, p)
  1641. MAXROWS used in all routines
  1642. Junked most global communication variables
  1643. @
  1644. text
  1645. @d404 2
  1646. a405 2
  1647. #define goal    1500000.0   /* Try to get up to 1.5 seconds            */
  1648. #define enough  1000000.0   /* But settle for 1.0 seconds            */
  1649. d412 2
  1650. a413 1
  1651.        reps to last more than a second.
  1652. @
  1653.  
  1654.  
  1655. 2.4
  1656. log
  1657. @All syncs use harder hardware sync rather than just XSync.
  1658. # objects/second rounded to 3 significant digits.
  1659. @
  1660. text
  1661. @d1 23
  1662. d33 1
  1663. a33 1
  1664. static Bool drawToGPX = False;
  1665. d36 5
  1666. a42 1
  1667. int fgPixel, bgPixel;
  1668. d46 6
  1669. a51 5
  1670. static XRectangle ws[] = {
  1671.     {300, 280, 90, 90},
  1672.     {150, 250, 90, 90},
  1673.     {450, 310, 90, 90}
  1674.   };
  1675. d55 4
  1676. a83 1
  1677.  
  1678. d88 1
  1679. a88 2
  1680.     if (firsttime)
  1681.     {
  1682. d95 1
  1683. a95 2
  1684.     if (current_time.low < basetime.low)
  1685.     {
  1686. a104 2
  1687. /*             time related stuff */
  1688.  
  1689. d121 2
  1690. a122 1
  1691. double ElapsedTime()
  1692. d133 1
  1693. a133 1
  1694.             (1000000.0 * (double)(stop.tv_sec - start.tv_sec));
  1695. d171 1
  1696. d175 1
  1697. d180 6
  1698. a185 1
  1699. /*                    generic X stuff */
  1700. d194 2
  1701. a195 2
  1702.     int *pargc;  /* MODIFIED */
  1703.     char **argv; /* MODIFIED */
  1704. d197 4
  1705. a200 4
  1706.     int argc = *pargc;
  1707.     char **pargv = argv+1;
  1708.     char *displayname = NULL;
  1709.     int i;
  1710. d202 1
  1711. a202 1
  1712.     for (i = 1; i < argc; i++) {
  1713. d213 2
  1714. a214 3
  1715.         while (i<argc)
  1716.             *pargv++ = argv[i++];
  1717.         break;
  1718. d228 1
  1719. a228 1
  1720. char *display_name;
  1721. d230 1
  1722. a230 1
  1723.     Display *d;
  1724. d232 7
  1725. a238 7
  1726.     d = XOpenDisplay(display_name);
  1727.     if (d == NULL) {
  1728.         fprintf (stderr, "%s:  unable to open display '%s'\n",
  1729.              program_name, XDisplayName (display_name));
  1730.         usage ();
  1731.         /* doesn't return */
  1732.     }
  1733. d240 1
  1734. a240 1
  1735.     return(d);
  1736. d243 3
  1737. a245 1
  1738. /*        stuff just for perf */
  1739. d247 1
  1740. d250 2
  1741. a251 2
  1742.     char **cpp;
  1743.     int i = 0;
  1744. d269 1
  1745. a269 2
  1746.     while (test[i].option != NULL)
  1747.     {
  1748. d275 6
  1749. d284 3
  1750. a286 3
  1751. void HardwareSync(d, w)
  1752.     Display *d;
  1753.     Window  w;
  1754. a287 13
  1755.     if (w == NULL) {
  1756.     XSync (d, True);
  1757.     } else {
  1758.     /*
  1759.      * Some graphics hardware allows the server to claim it is done,
  1760.      * while in reality the hardware is busily working away.  So fetch
  1761.      * a pixel from the window that was drawn to, which should be
  1762.      * enough to make the server wait for the graphics hardware.
  1763.      */
  1764.     XImage *i;
  1765.     i = XGetImage(d, w, 1, 1, 1, 1, ~0, ZPixmap);
  1766.     XDestroyImage(i);
  1767.     }
  1768. d290 6
  1769. a295 2
  1770. /* Main window created (if any) that the current benchmark draws to. */
  1771. static Window perfWindow;
  1772. d297 3
  1773. a299 4
  1774. DoTest(d, test, label)
  1775.     Display *d;
  1776.     Test *test;
  1777.     char *label;
  1778. d301 7
  1779. a307 2
  1780.     double  time;
  1781.     int     ret_width, ret_height;
  1782. d309 3
  1783. a311 4
  1784.     HardwareSync (d, perfWindow);
  1785.     InitTimes ();
  1786.     (*test->proc) (d, &test->parms);
  1787.     HardwareSync(d, perfWindow);
  1788. d313 9
  1789. a321 7
  1790.     time = ElapsedTime();
  1791.     ReportTimes (time, test->parms.reps * test->parms.objects, label);
  1792.     if (drawToGPX)
  1793.         XQueryBestSize(d, TileShape, tileToQuery,
  1794.                32, 32, &ret_width, &ret_height);
  1795.     if (test->passCleanup != NULL)
  1796.     (*test->passCleanup) (d, &test->parms);
  1797. d324 5
  1798. d330 4
  1799. a333 3
  1800. Window CreatePerfWindow(d, x, y, width, height)
  1801.     Display *d;
  1802.     int width, height, x, y;
  1803. d339 4
  1804. a342 4
  1805.     w = XCreateSimpleWindow (
  1806.         d, RootWindow (d, 0), x, y, width, height, 1, fgPixel, bgPixel);
  1807.     XChangeWindowAttributes (d, w, CWOverrideRedirect, &xswa);
  1808.     XMapWindow (d, w);
  1809. d347 2
  1810. a348 3
  1811.  
  1812. void CreateClipWindows(display, clips)
  1813.     Display *display;
  1814. d352 1
  1815. d354 1
  1816. d356 3
  1817. a358 3
  1818.     for (j = 0; j < clips; j++) {
  1819.     clipWindows[j] = CreatePerfWindow(display,
  1820.         ws[j].x, ws[j].y, ws[j].width, ws[j].height);
  1821. d362 3
  1822. a364 2
  1823. void DestroyClipWindows(display, clips)
  1824.     Display *display;
  1825. d370 2
  1826. a371 2
  1827.     for (j = 0; j < clips; j++) {
  1828.     XDestroyWindow(display, clipWindows[j]);
  1829. d376 7
  1830. d384 19
  1831. a402 4
  1832. Bool CalibrateTest(d, test, seconds)
  1833.     Display *d;
  1834.     Test *test;
  1835.     int seconds;
  1836. d404 4
  1837. d411 2
  1838. a412 3
  1839.     /* Attempt to get an idea how long each rep lasts by first getting enough
  1840.        reps to last more than a second.  Then set p->reps to run long
  1841.        enough to do enough reps to last as many seconds as the guy asked for.
  1842. d420 4
  1843. a423 8
  1844.     if (test->init != NULL) {
  1845.         if (! ((*test->init) (d, &test->parms))) {
  1846.         return False;
  1847.         }
  1848.         /* Create clip windows if requested */
  1849.         if (perfWindow != NULL) {
  1850.         CreateClipWindows(d, test->clips);
  1851.         }
  1852. d425 3
  1853. a427 1
  1854.     HardwareSync(d, perfWindow);
  1855. d429 7
  1856. a435 10
  1857.     (*test->proc) (d, &test->parms);
  1858.     HardwareSync(d, perfWindow);
  1859.     usecs = ElapsedTime();
  1860.     if (test->passCleanup != NULL)
  1861.         (*test->passCleanup) (d, &test->parms);
  1862.     if (test->cleanup != NullProc)
  1863.         (*test->cleanup) (d, &test->parms);
  1864.     if (perfWindow != NULL) {
  1865.         DestroyClipWindows(d, test->clips);
  1866.     }
  1867. d438 1
  1868. d442 1
  1869. a442 1
  1870.     if (usecs >= 1000000.0) break;
  1871. d444 2
  1872. a445 2
  1873.     /* Assume that it took 1/100 sec if we didn't get a clock tick. */
  1874.     if (usecs == 0.0) usecs = 10000.0;
  1875. d447 2
  1876. a448 3
  1877.     /* Try to get up to 1.5 seconds. */
  1878.     reps = (int) (1500000.0 * (double)reps / usecs) + 1;
  1879.  
  1880. d451 1
  1881. d468 2
  1882. a469 5
  1883. void CreatePerfStuff(d, count, width, height, w, bggc, fggc)
  1884.     Display *d;
  1885.     int width, height, count;
  1886.     Window *w;
  1887.     GC *bggc, *fggc;
  1888. a471 2
  1889.     XSetWindowAttributes xswa;
  1890.     int i;
  1891. d473 3
  1892. a475 4
  1893.     xswa.override_redirect = True;
  1894.     for (i = 0; i < count; i++) {
  1895.     w[i] = CreatePerfWindow(d, 2+i*width, 2+i*height, width, height);
  1896.     }
  1897. d477 4
  1898. a480 4
  1899.     if (count != 0) {
  1900.     /* Stash away main graphics window */
  1901.     perfWindow = w[0];
  1902.     }
  1903. d482 5
  1904. a486 44
  1905.     if (bggc != NULL) {
  1906. #ifdef testingxor
  1907.     gcv.foreground = bgPixel ^ fgPixel;
  1908.     gcv.background = ~gcv.foreground;
  1909.     gcv.function = GXinvert;
  1910.     gcv.plane_mask = bgPixel ^ fgPixel;
  1911.     *bggc = XCreateGC(d, w[0],
  1912.       GCForeground | GCBackground | GCFunction | GCPlaneMask, &gcv);
  1913. #else
  1914. # ifdef testingandor
  1915.     gcv.foreground = 1;
  1916.     gcv.background = 0;
  1917.     gcv.function = GXor;
  1918.     gcv.plane_mask = 1;
  1919.     *bggc = XCreateGC(d, w[0],
  1920.       GCForeground | GCBackground | GCFunction | GCPlaneMask, &gcv);
  1921. # else
  1922.     gcv.foreground = bgPixel;
  1923.     gcv.background = fgPixel;
  1924.     *bggc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
  1925. # endif
  1926. #endif
  1927.     }
  1928.     if (fggc != NULL) {
  1929. #ifdef testingxor
  1930.     gcv.foreground = bgPixel ^ fgPixel;
  1931.     gcv.background = ~gcv.foreground;
  1932.     gcv.function = GXxor;
  1933.     *fggc = XCreateGC(d, w[0],
  1934.       GCForeground | GCBackground | GCFunction, &gcv);
  1935. #else
  1936. # ifdef testingandor
  1937.     gcv.foreground = 0;
  1938.     gcv.background = 1;
  1939.     gcv.function = GXand;
  1940.     *fggc = XCreateGC(d, w[0],
  1941.       GCForeground | GCBackground | GCFunction, &gcv);
  1942. # else
  1943.     gcv.foreground = fgPixel;
  1944.     gcv.background = bgPixel;
  1945.     *fggc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
  1946. # endif
  1947. #endif
  1948.     }
  1949. d515 18
  1950. a532 1
  1951. Window root;
  1952. d542 1
  1953. a542 1
  1954.     Display * display;
  1955. d545 4
  1956. a548 2
  1957.     Bool foundOne = False;
  1958.     Bool synchronous = False;
  1959. d553 6
  1960. d560 1
  1961. d564 1
  1962. d567 1
  1963. a567 1
  1964.     for (i = 1; i < argc; i++) {
  1965. d575 1
  1966. a575 1
  1967.         drawToGPX = True;
  1968. d612 1
  1969. a612 1
  1970.     display = Open_Display (displayName);
  1971. d616 1
  1972. a616 1
  1973.         ServerVendor (display), DisplayString (display), hostname);
  1974. d619 1
  1975. a619 1
  1976.         ServerVendor (display), DisplayString (display));
  1977. d624 1
  1978. a624 1
  1979.     XGetScreenSaver(display, &ssTimeout, &ssIntervalReturn, &ssPreferBlanking,
  1980. d626 2
  1981. a627 2
  1982.     XForceScreenSaver(display, ScreenSaverReset);
  1983.     XSetScreenSaver(display, 0, 0, DefaultBlanking, DefaultExposures);
  1984. d629 4
  1985. a632 3
  1986.     root = RootWindow (display, 0);
  1987.     if (drawToGPX) {
  1988.         tileToQuery = XCreatePixmap(display, root, 32, 32, 1);
  1989. d636 8
  1990. a643 2
  1991.     fgPixel = AllocateColor(display, foreground, BlackPixel(display, 0));
  1992.     bgPixel = AllocateColor(display, background, WhitePixel(display, 0));
  1993. d646 7
  1994. a652 1
  1995.     XSynchronize (display, True);
  1996. d658 3
  1997. a665 2
  1998.             if (reps > 10)
  1999.             test[i].parms.reps = reps/test[i].parms.objects;
  2000. d671 6
  2001. a676 4
  2002.         perfWindow = NULL;
  2003.         if (CalibrateTest(display, &test[i], seconds)) {
  2004.             if (test[i].init != NULL)
  2005.             (void)(*test[i].init) (display, &test[i].parms);
  2006. d678 1
  2007. a678 3
  2008.             if (perfWindow != NULL) {
  2009.             CreateClipWindows(display, test[i].clips);
  2010.             }
  2011. d680 4
  2012. a683 7
  2013.             for (j = 0; j < repeat; j++)
  2014.             DoTest (display, &test[i], label);
  2015.             if (test[i].cleanup != NullProc)
  2016.             (*test[i].cleanup) (display, &test[i].parms);
  2017.             if (perfWindow != NULL) {
  2018.             DestroyClipWindows(display, test[i].clips);
  2019.             }
  2020. d692 1
  2021. d695 1
  2022. d697 1
  2023. a697 1
  2024.     XSetScreenSaver(display, ssTimeout, ssIntervalReturn, ssPreferBlanking,
  2025. @
  2026.  
  2027.  
  2028. 2.3
  2029. log
  2030. @Self-timing calibration, better fg/bg color parsing
  2031. @
  2032. text
  2033. @d94 1
  2034. a94 2
  2035. void GetTime (usec)
  2036.     int *usec;
  2037. d100 1
  2038. a100 2
  2039.     if (stop.tv_usec < start.tv_usec)
  2040.     {
  2041. d104 2
  2042. a105 2
  2043.     *usec = stop.tv_usec - start.tv_usec +
  2044.             (1000000 * (stop.tv_sec - start.tv_sec));
  2045. d108 2
  2046. a109 4
  2047. void ReportTimes(usec, n, str)
  2048.     int usec;
  2049.     int n;
  2050.     char *str;
  2051. d111 2
  2052. a112 1
  2053.     int usecperobj, objpersec;
  2054. d114 17
  2055. a130 4
  2056.     usecperobj = (usec * 10) / n;
  2057.     objpersec = (int) ((double) n * 1000000.0 / (double) usec + 0.5);
  2058.     printf("%6d reps @@ %2d.%04d msec (%4d/sec): %s\n", 
  2059.     n, usecperobj/10000, usecperobj%10000, objpersec, str);
  2060. d133 17
  2061. d242 1
  2062. a242 1
  2063. void EndSync(d, w)
  2064. d247 1
  2065. a247 1
  2066.     XSync (d, 0);
  2067. d269 1
  2068. a269 1
  2069.     int     r;
  2070. d272 1
  2071. a272 1
  2072.     XSync (d, True);
  2073. d275 1
  2074. a275 1
  2075.     EndSync(d, perfWindow);
  2076. d277 2
  2077. a278 2
  2078.     GetTime (&r);
  2079.     ReportTimes (r, test->parms.reps * test->parms.objects, label);
  2080. d336 2
  2081. a337 2
  2082.     int usecs;
  2083.     int reps, exponent;
  2084. d358 1
  2085. a358 1
  2086.     XSync(d, 0);
  2087. d361 2
  2088. a362 2
  2089.     EndSync(d, perfWindow);
  2090.     GetTime(&usecs);
  2091. d375 1
  2092. a375 1
  2093.     if (usecs >= 1000000) break;
  2094. d378 1
  2095. a378 1
  2096.     if (usecs == 0) usecs = 10000;
  2097. d381 1
  2098. a381 1
  2099.     reps = (int) (1500000.0 * (double)reps / (double)usecs) + 1;
  2100. d385 1
  2101. a385 2
  2102.     reps = (int) ((double)seconds * 1000000.0 * (double)reps 
  2103.             / (double)usecs) + 1;
  2104. d387 2
  2105. a388 2
  2106.     /* Now round reps up to 1 digit accuracy, so we don't get really weird
  2107.        numbers coming out */
  2108. a625 1
  2109.             printf("FAILED TEST: %s\n", test[i].label);
  2110. @
  2111.  
  2112.  
  2113. 2.2
  2114. log
  2115. @Massive changes, I'm not going to go into details.
  2116. @
  2117. text
  2118. @d20 3
  2119. a22 3
  2120.     {150, 150, 90, 90},
  2121.     {300, 180, 90, 90},
  2122.     {450, 210, 90, 90}
  2123. d110 2
  2124. a111 2
  2125. void ReportTimes(r, n, str)
  2126.     int  r;
  2127. d115 6
  2128. a120 2
  2129.     r /= n;
  2130.     printf("%6d repetitions @@ %2d.%03d millisec/%s\n", n, r/1000, r%1000, str);
  2131. d192 2
  2132. a193 1
  2133. "    -repeat <n>\t        do tests <n> times (default = 5)",
  2134. d215 1
  2135. a215 4
  2136. /* Main window created (if any) that the current benchmark draws to. */
  2137. static Window perfWindow;
  2138.  
  2139. DoTest(d, test, label)
  2140. d217 1
  2141. a217 2
  2142.     Test *test;
  2143.     char *label;
  2144. d219 1
  2145. a219 7
  2146.     int     r;
  2147.     int     ret_width, ret_height;
  2148.  
  2149.     XSync (d, 0);
  2150.     InitTimes ();
  2151.     (*test->proc) (d, &test->parms);
  2152.     if (perfWindow == NULL) {
  2153. d229 1
  2154. a229 1
  2155.     i = XGetImage(d, perfWindow, 1, 1, 1, 1, ~0, ZPixmap);
  2156. d232 1
  2157. d234 16
  2158. d277 98
  2159. d387 1
  2160. a387 1
  2161.     w[i] = CreatePerfWindow(d, 50+i*width, 50+i*height, width, height);
  2162. d441 4
  2163. a444 3
  2164. void CreateClipWindows(display, clips)
  2165.     Display *display;
  2166.     int     clips;
  2167. d446 2
  2168. a447 1
  2169.     int j;
  2170. d449 2
  2171. a450 6
  2172.     if (clips > MAXCLIP) clips = MAXCLIP;
  2173.     for (j = 0; j < clips; j++) {
  2174.     clipWindows[j] = CreatePerfWindow(display,
  2175.         ws[j].x, ws[j].y, ws[j].width, ws[j].height);
  2176.     }
  2177. } /* CreateClipWindows */
  2178. d452 11
  2179. a462 9
  2180. void DestroyClipWindows(display, clips)
  2181.     Display *display;
  2182.     int     clips;
  2183. {
  2184.     int j;
  2185.  
  2186.     if (clips > MAXCLIP) clips = MAXCLIP;
  2187.     for (j = 0; j < clips; j++) {
  2188.     XDestroyWindow(display, clipWindows[j]);
  2189. d464 2
  2190. a465 1
  2191. } /* DestroyClipWindows */
  2192. a466 2
  2193.  
  2194.  
  2195. d479 1
  2196. d483 4
  2197. d505 1
  2198. a505 1
  2199.         if (repeat == 0)
  2200. d507 6
  2201. d548 6
  2202. d560 2
  2203. a561 5
  2204.     fgPixel = BlackPixel(display, 0);
  2205.     bgPixel = WhitePixel(display, 0);
  2206.     if (foreground != NULL) {
  2207.     /* Try to allocate a foreground color as specified */
  2208.     XColor def, cdef;
  2209. a562 20
  2210.     if (XAllocNamedColor(display,
  2211.         XDefaultColormap(display, DefaultScreen(display)),
  2212.         foreground, &def, &cdef)) {
  2213.         fgPixel = def.pixel;
  2214.     } else {
  2215.         (void) fprintf(stderr, "Cannot allocate color %s\n", foreground);
  2216.     }
  2217.     }
  2218.     if (background != NULL) {
  2219.     /* Try to allocate a background color as specified */
  2220.     XColor def, cdef;
  2221.     if (XAllocNamedColor(display,
  2222.         XDefaultColormap(display, DefaultScreen(display)),
  2223.         background, &def, &cdef)) {
  2224.         bgPixel = def.pixel;
  2225.     } else {
  2226.         (void) fprintf(stderr, "Cannot allocate color %s\n", background);
  2227.     }
  2228.     }
  2229.  
  2230. d577 1
  2231. a577 1
  2232.             sprintf (label, "%s (%d children)",
  2233. d583 3
  2234. a585 2
  2235.         if (test[i].init == NULL ||
  2236.             ((*test[i].init) (display, &test[i].parms))) {
  2237. d590 1
  2238. d600 1
  2239. d609 4
  2240. @
  2241.  
  2242.  
  2243. 2.1
  2244. log
  2245. @Make any benchmark that creates a window to write to actually try to read
  2246. data back from that window.  This insures that machines like the GPX don't
  2247. lie about being done with an operation, when in reality the graphics
  2248. accelerator is chugging away.
  2249. @
  2250. text
  2251. @d17 10
  2252. d331 27
  2253. d365 1
  2254. d373 3
  2255. d381 1
  2256. a381 1
  2257.         test[j].doit = True;
  2258. d406 1
  2259. a406 1
  2260.             test[j].doit = True;
  2261. d463 1
  2262. a463 1
  2263.     if (test[i].doit) {
  2264. d476 2
  2265. a478 2
  2266.         else
  2267.             strcpy (label, test[i].label);
  2268. d480 16
  2269. a495 6
  2270.         if (test[i].init != NullProc)
  2271.             (*test[i].init) (display, &test[i].parms);
  2272.         for (j = 0; j < repeat; j++)
  2273.             DoTest (display, &test[i], label);
  2274.         if (test[i].cleanup != NullProc)
  2275.             (*test[i].cleanup) (display, &test[i].parms);
  2276. @
  2277.  
  2278.  
  2279. 2.0
  2280. log
  2281. @version from /usr/src/pmax
  2282. @
  2283. text
  2284. @d200 3
  2285. d214 14
  2286. a227 1
  2287.     XSync (d, 0);
  2288. d253 2
  2289. d267 1
  2290. a267 1
  2291.     w[i] = CreatePerfWindow(d, 50, 50, width, height);
  2292. d270 5
  2293. d438 1
  2294. @
  2295.  
  2296.  
  2297. 1.6
  2298. log
  2299. @No changes
  2300. @
  2301. text
  2302. @@
  2303.  
  2304.  
  2305. 1.5
  2306. log
  2307. @Added -fg -bg capabilities
  2308. Added tiled rectangles
  2309. @
  2310. text
  2311. @d375 1
  2312. @
  2313.  
  2314.  
  2315. 1.4
  2316. log
  2317. @Added stuff for testing weird functions with planemask
  2318. @
  2319. text
  2320. @d13 4
  2321. d20 2
  2322. a21 2
  2323.      unsigned long low;
  2324.      unsigned long high;
  2325. d25 2
  2326. a26 2
  2327.        long tv_sec;        /* seconds since Jan. 1, 1970 */
  2328.        long tv_usec;  /* and microseconds */
  2329. d30 2
  2330. a31 2
  2331.        int  tz_minuteswest;     /* of Greenwich */
  2332.        int  tz_dsttime;    /* type of dst correction to apply */
  2333. d181 2
  2334. d231 1
  2335. a231 2
  2336.         d, RootWindow (d, 0), x, y, width, height, 1,
  2337.         BlackPixel (d, 0), WhitePixel (d, 0));
  2338. d237 1
  2339. a237 1
  2340. void CreatePerfStuff(d, count, width, height, w, whitegc, blackgc)
  2341. d241 1
  2342. a241 1
  2343.     GC *whitegc, *blackgc;
  2344. d252 3
  2345. a254 3
  2346.     if (whitegc != NULL) {
  2347. #ifdef new
  2348.     gcv.foreground = WhitePixel(d, 0) ^ BlackPixel(d, 0);
  2349. d257 2
  2350. a258 2
  2351.     gcv.plane_mask = WhitePixel(d, 0) ^ BlackPixel(d, 0);
  2352.     *whitegc = XCreateGC(d, w[0],
  2353. d261 12
  2354. a272 3
  2355.     gcv.foreground = WhitePixel(d, 0);
  2356.     gcv.background = BlackPixel(d, 0);
  2357.     *whitegc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
  2358. d275 3
  2359. a277 3
  2360.     if (blackgc != NULL) {
  2361. #ifdef new
  2362.     gcv.foreground = WhitePixel(d, 0) ^ BlackPixel(d, 0);
  2363. d280 1
  2364. a280 1
  2365.     *blackgc = XCreateGC(d, w[0],
  2366. d283 11
  2367. a293 3
  2368.     gcv.foreground = BlackPixel(d, 0);
  2369.     gcv.background = WhitePixel(d, 0);
  2370.     *blackgc = XCreateGC(d, w[0], GCForeground | GCBackground , &gcv);
  2371. d318 31
  2372. a348 1
  2373.         foundOne = True;;
  2374. a349 26
  2375.     else
  2376.         if (strcmp (argv[i], "-sync") == 0) {
  2377.         synchronous = True;
  2378.         }
  2379.         else if (strcmp (argv[i], "-draw") == 0) {
  2380.         drawToGPX = True;
  2381.         }
  2382.         else
  2383.         if (strcmp (argv[i], "-repeat") == 0) {
  2384.             if (argc <= i)
  2385.             usage ();
  2386.             repeat = atoi (argv[++i]);
  2387.             if (repeat == 0)
  2388.             usage ();
  2389.         }
  2390.         else {
  2391.             ForEachTest (j) {
  2392.             if (strcmp (argv[i], test[j].option) == 0) {
  2393.                 test[j].doit = True;
  2394.                 goto LegalOption;
  2395.             }
  2396.             }
  2397.             usage ();
  2398.         LegalOption: 
  2399.             foundOne = True;
  2400.         }
  2401. d368 27
  2402. @
  2403.  
  2404.  
  2405. 1.3
  2406. log
  2407. @no change
  2408. @
  2409. text
  2410. @d248 8
  2411. d259 1
  2412. d262 7
  2413. d272 1
  2414. @
  2415.  
  2416.  
  2417. 1.2
  2418. log
  2419. @Susan's changes to display after each test on GPX
  2420. @
  2421. text
  2422. @@
  2423.  
  2424.  
  2425. 1.1
  2426. log
  2427. @Initial revision
  2428. @
  2429. text
  2430. @d10 3
  2431. d175 1
  2432. d200 1
  2433. d206 1
  2434. a206 1
  2435.   GetTime (&r);
  2436. d208 3
  2437. d285 3
  2438. d322 3
  2439. @
  2440.