home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gs333ini / gs3.33 / bench.ps < prev    next >
Text File  |  1995-12-09  |  3KB  |  90 lines

  1. %    Copyright (C) 1993, 1994 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % bench.ps
  16. % This file is a "wrapper" for benchmarking.
  17. % It writes timing results on a file called:
  18.  
  19. /BOF where { pop } {
  20.   /BOF (bench.out) def
  21. } ifelse
  22.  
  23.         % Switch to global VM so odef will work.
  24.  
  25. /currentglobal where
  26.  { pop currentglobal true setglobal /setglobal cvx }
  27.  { { } }
  28. ifelse
  29.  
  30.         % Make sure all execution occurs under a `save'.
  31.  
  32. save pop
  33.  
  34.         % Set the output device to an image device.
  35.  
  36. (%END) .skipeof            %****************
  37.  
  38. /Resolution where { pop } { /Resolution 100 def } ifelse
  39. [ Resolution 72.0 div 0 0 Resolution -72.0 div 0 792 ]
  40.   Resolution 8.5 mul cvi
  41.   Resolution 11.0 mul cvi
  42.   <00 ff>
  43. makeimagedevice
  44. setdevice
  45.  
  46. %END
  47.  
  48.         % Redefine 'run' so that it collects timing information.
  49.  
  50. /.orig.run /run load def
  51. /.run.finish    % <file> <time> .run.finish <file>
  52.  { usertime exch sub
  53.    1 index =string cvs .bench.file exch writestring
  54.    .bench.file (: run time = ) writestring
  55.    =string cvs .bench.file exch writestring
  56.    .bench.file ( ms\n) writestring
  57.    .bench.file flushfile
  58.  } bind def
  59. /run        % <string> run -
  60.  {        % We construct a bound procedure here so that
  61.         % we can invoke run recursively.
  62.    cvlit
  63.    2
  64.     { /.orig.run load
  65.       save countdictstack 3 index usertime /.run.finish cvx
  66.       7 array astore cvx exec
  67.       exch countdictstack exch sub { end } repeat
  68.       exch restore
  69.     }
  70.    repeat
  71.         % Don't do the save & restore the last time.
  72.    /.orig.run load
  73.    1 index usertime /.run.finish cvx
  74.    5 array astore cvx exec pop
  75.  } bind odef
  76.  
  77.         % Force a quit after processing files.
  78.  
  79. /.bench.file BOF (w) file def
  80. /executive { .bench.file closefile quit } def
  81.  
  82.         % Make sure we don't incur any pauses.
  83.  
  84. /NOPAUSE true def
  85.  
  86. exec        % restore currentglobal
  87.