🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #4115

Here is a postscript information/benchmark program

#4115
From: Andy Kinsman 253-7794
Date: Fri, 09 Oct 1992 20:29
575 lines
12961 bytes
%!
%
%   psparams.ps - display some interesting things about the device
%            this code is executing on.
%		- run a few benchmarks.
%
%   (C) 1992 Andrew A. Kinsman.  All rights reserved.
%
%
/Times-Roman findfont 12 scalefont setfont
/inch { 72 mul } def
/line-feed { 0 -.16 inch translate 0 0 moveto } def
/do-last-page true def     % contains optional performance tests

%
%  dump return values
%    ( literal dictionary-name -- )
/dump-returns {
	mark 3 1 roll	  % mark stack
	cvx exec begin
	cvx exec end	  % convert and execute it
	counttomark
	(  ) show
	-1 1 {
		1 sub index     % get the nth-1 down the stack
		30 string cvs show
		( ) show
	    } for
	cleartomark       % trash all returns
} def

%
%
%   print-dict-exec ( literal-key -- )  
%         - print the name of the dictionary a key is found in.
%         - and call dump-returns to execute it.
%
/print-dict-exec {
	dup			% print the dictionary it is found in.
	userdict   exch known { line-feed
				(userdict:)   show 
				dup 20 string cvs show
				dup (userdict) dump-returns
			      } if

	dup
	systemdict exch known { line-feed
				(systemdict:)   show 
				dup 20 string cvs show
				dup (systemdict) dump-returns
			      } if

	dup
	statusdict exch known { line-feed
				(statusdict:)   show 
				dup 20 string cvs show
				dup (statusdict) dump-returns
			      } if

	dup
	errordict  exch known { line-feed
				(errordict:)   show 
				dup 20 string cvs show
				dup (errordict) dump-returns
			      } if

	dup
	systemdict /serverdict known {   % possibly no serverdict?
		serverdict   exch known { line-feed
				(serverdict:)   show 
				dup 20 string cvs show
				dup (serverdict) dump-returns
			      } if
		} if

	pop
} def

%
%
%   print-dict ( literal-key -- )  
%         - print the name of the dictionary a key is found in.
%
/print-dict {
	dup			% print the dictionary it is found in.
	userdict   exch known { line-feed
				(userdict:)   show 
				dup 20 string cvs show
			      } if

	dup
	systemdict exch known { line-feed
				(systemdict:)   show 
				dup 20 string cvs show
			      } if

	dup
	statusdict exch known { line-feed
				(statusdict:)   show 
				dup 20 string cvs show
			      } if

	dup
	errordict  exch known { line-feed
				(errordict:)   show 
				dup 20 string cvs show
			      } if

	dup
	systemdict /serverdict known {   % possibly no serverdict?
		serverdict   exch known { line-feed
				(serverdict:)   show 
				dup 20 string cvs show
			      } if
		} if

	pop
} def

erasepage
%
% mark imagable area with gray dotted line
gsave
0.6 setgray
1 setlinewidth
[5] 0 setdash
clippath stroke
grestore

% mark corners of default bounding box
	newpath clippath pathbbox newpath
	2 copy .5 inch sub exch 2.2 inch sub exch moveto
	1 index 10 string cvs show (,) show
	0 index 10 string cvs show 
	2 copy .5 inch sub exch .5 inch sub exch moveto lineto stroke

	2 copy .5 inch add exch .5 inch add exch moveto
	1 index 10 string cvs show (,) show
	0 index 10 string cvs show 
	2 copy .5 inch add exch .5 inch add exch moveto lineto stroke

% goto top of page
gsave
1 inch 10.8 inch translate

% major information at top
line-feed
line-feed
line-feed
	(PostScript printer analysis and benchmark - page 1) show
line-feed
	((C) 1992 Andrew A. Kinsman) show
line-feed
line-feed
	(This was printed on a ") show
	statusdict begin product end show
	(" printer.) show
line-feed
	(Version ) show
	statusdict begin version end 10 string cvs show
line-feed
	/resmatrix matrix def
	/findresolution {
  		72 0 resmatrix defaultmatrix dtransform
        	/yres exch def /xres exch def
        	xres dup mul yres dup mul add sqrt
 	 } def
	(Device resolution is ) show
	findresolution 10 string cvs show
	( dots/inch.) show

% default TM helpful
line-feed
	matrix defaultmatrix
	(Default transformation matrix is:) show
line-feed
	(  [) show
	dup 0 get 10 string cvs show ( ) show
	dup 1 get 10 string cvs show ( ) show
	dup 2 get 10 string cvs show ( ) show
	dup 3 get 10 string cvs show ( ) show
	dup 4 get 10 string cvs show ( ) show
	    5 get 10 string cvs show (].) show

% display some information about the dictionaries
line-feed
	(Dictionary stack has ) show
	countdictstack 10 string cvs show
	( dictionaries on it.) show

% password open?
	statusdict begin
		0 checkpassword 
	end
	{ line-feed (Server password is zero.) show
	} if

%
% dictionary permisions checker
%
/d-perm-check {
	dup
	rcheck { (R) show } { (-) show } ifelse
	dup
	wcheck { (W) show } { (-) show } ifelse
	xcheck { (X) show } { (-) show } ifelse
	( ) show
} def

line-feed
line-feed
	(Dictionary attributes:) show
line-feed
	userdict d-perm-check
	(userdict) show	 
	2 inch 0 inch moveto userdict length 10 string cvs show
	( used of ) show
	userdict maxlength 10 string cvs show
	( entries.) show

line-feed
	systemdict d-perm-check
	(systemdict) show	 
	2 inch 0 inch moveto systemdict length 10 string cvs show
	( used of ) show
	systemdict maxlength 10 string cvs show
	( entries.) show

line-feed
	statusdict d-perm-check
	(statusdict) show	 
	2 inch 0 inch moveto statusdict length 10 string cvs show
	( used of ) show
	statusdict maxlength 10 string cvs show
	( entries.) show

line-feed
	errordict d-perm-check
	(errordict) show	 
	2 inch 0 inch moveto errordict length 10 string cvs show
	( used of ) show
	errordict maxlength 10 string cvs show
	( entries.) show

systemdict /serverdict known     % possibly no serverdict
{
line-feed
	serverdict d-perm-check
	(serverdict) show	 
	2 inch 0 inch moveto serverdict length 10 string cvs show
	( used of ) show
	serverdict maxlength 10 string cvs show
	( entries.) show
} if

% VM usage
line-feed
line-feed
	vmstatus
	(VM status- level: ) show
	2 index 10 string cvs show
	( used: ) show
	1 index 10 string cvs show
	( max: ) show
	0 index 10 string cvs show
	pop pop pop

% some interesting words, if they exist, and the values they return
% lazy writer ops, and some linotronics
line-feed
line-feed
(The following operators exist and report these values:) show
/currentscreen		print-dict-exec
/dostartpage		print-dict-exec
/filmcounter		print-dict-exec
/jobname		print-dict-exec
/jobtimeout		print-dict-exec
/manualfeed		print-dict-exec
/manualfeedtimeout	print-dict-exec
/margins		print-dict-exec
/measure		print-dict-exec
/mirrorprint		print-dict-exec
/negativeprint		print-dict-exec
/pagecount		print-dict-exec
/pageparams		print-dict-exec
/pagestackorder		print-dict-exec
/pagetype		print-dict-exec
/prefeed		print-dict-exec
/revision		print-dict-exec
/waittimeout		print-dict-exec

% don't execute the following, they may hang it.
line-feed
line-feed
(The following page sizes exist:) show
/letter			print-dict
/Letter			print-dict
/note			print-dict
/legal			print-dict
/11x17			print-dict
/ledger			print-dict
/a3			print-dict
/a4			print-dict
/A4			print-dict
/a5			print-dict
/A5			print-dict
/b5			print-dict
/B5			print-dict

grestore
showpage

% page 2
% available fonts include....
gsave
1 inch 10.8 inch translate
line-feed
line-feed
line-feed
	(PostScript printer analysis and benchmark - ) show
	statusdict begin product end show
	( - ) show
	( page 2) show
line-feed
	((C) 1992 Andrew A. Kinsman) show
line-feed
line-feed
(The following fonts exist in the FontDirectory:) show

%  dump-dict ( dictionary level -- )
/dump-dict {
   dup 2 lt                % restrict depth to this number
   {  exch                 % ( level dict -- )
      {                    % ( level key value -- )
	dup type /dicttype eq % only display and recurse into dicts.
	{
	  line-feed          % ( level key value -- )
			     % indent "level" blanks
	  2 index 4 mul { ( ) show } repeat
	  1 index 50 string cvs show  % display key
	  gsave
	  0 index 12 scalefont setfont
	  3.25 inch 0 moveto (The Quick Red Fox Jumped) show
	  grestore
	  dup 3 index 1 add dump-dict % recurse
	} if
	pop pop            % toss key value pair
      } forall
      pop                  % toss level
   }
   { pop pop               % toss dictionary and level
   } ifelse
} def
systemdict /FontDirectory get 1 dump-dict
showpage
grestore

% page 3 performance tests
do-last-page {
gsave
1 inch 10.8 inch translate
line-feed
line-feed
line-feed
	(PostScript printer analysis and benchmark - ) show
	statusdict begin product end show
	( - ) show
	( page 3) show
line-feed
	((C) 1992 Andrew A. Kinsman) show
grestore
gsave
%
% performance test
% forever to be known as the Fresnel benchmark for
% PostScript printers.
%
/lamda .000055 def		% wavelength (cm)
/dist  5       def		% dist to focus (cm)
/colorcnt 16   def		% number of colors to use in ring

% circle at current center of a specific radius  ( radius - )
/circle { 0 exch 0 exch 0 360 arc } def

% translate to center of page
8.5 inch 2 div 8.0 inch translate

% get-radius  ( n -- radius-cm )
/get-radius {
        dup lamda mul 4 div dist add mul lamda mul sqrt
} def

%
% do-ring   ( outer-rad inner-rad -- ) 
/do-ring {
    /ring-color 1 def				% start at white
    2 copy sub colorcnt div neg exch		% colorcnt divisions or steps
       {
	 ring-color setgray
	 circle fill
	 ring-color 1 colorcnt div sub /ring-color exch def  % next color
       } for
} def
	

% scale up for easy viewing
70 70 scale

% draw circles, work from largest to smallest radius
% because postscipt is a paint over language
usertime
20 -1 1 {
		dup get-radius 		% compute outer radius (cm)
		2.54 div		% convert to inches
		inch			% convert to points

		exch 1 sub
		get-radius		% inner radius (cm)
		2.54 div		% convert to inches
		inch

		do-ring
	 }
	 for
grestore
gsave
usertime exch sub 1000 div
3.0 inch 5.8 inch translate
0 0 moveto 
(Fresnel benchmark: ) show
10 string cvs show
( secs.) show

grestore
gsave
%
% grayscale test pattern
%
usertime
2.25 inch 1.0 inch translate
gsave
/gscale 4.0 def
gscale inch dup scale

/str  ( ) def
/val  0 def

% grayscale image
16 16 8
[16 0 0 -16 0 16]
{ str 0 val put
  val 1 add /val exch def
  str }
image
grestore

% add vertical grating
1 setlinewidth
0 gscale 16 div gscale { inch dup 0 moveto gscale .1 add inch lineto stroke
	 } for

% add horizontile grating
1 setlinewidth
0 gscale 16 div gscale { inch dup 0 exch moveto gscale .1 add inch exch lineto stroke
	 } for

grestore
gsave
usertime exch sub 1000 div
3.0 inch .8 inch translate
0 0 moveto 
(Gray scale benchmark: ) show
10 string cvs show
( secs.) show

% details about known "printers" performance
% Fresnel benchmark
grestore
gsave
0.25 inch 9.8 inch translate
line-feed
(psh Sparc2) show
line-feed
(  1.659 secs.) show
line-feed
(pageview Sparc2) show
line-feed
(  2.713 secs.) show
line-feed
(Ghostscript 486-40MHZ) show
line-feed
(  7.580 secs.) show
line-feed
(Ghostscript Sparc2) show
line-feed
(  8.288 secs.) show
line-feed
(NeWS Server V2.1) show
line-feed
( 26.841 secs.) show
line-feed
(NeWS Server V3) show
line-feed
( 27.259 secs.) show
line-feed
(QMS-PS 810 Turbo) show
line-feed
( 39.947 secs.) show
line-feed
(QMS-PS 2210) show
line-feed
( 41.077 secs.) show
line-feed
(Ghostscript 286-12MHZ) show
line-feed
( 63.660 secs.) show
line-feed
(LaserWriter II NT) show
line-feed
(222.574 secs.) show
line-feed
(HP LaserJet IIIP) show
line-feed
(237.065 secs.) show

% grayscale benchmark
grestore
0.25 inch 5.0 inch translate
line-feed
(psh Sparc2) show
line-feed
(  0.117 secs.) show
line-feed
(pageview Sparc2) show
line-feed
(  0.146 secs.) show
line-feed
(Ghostscript 486-40MHZ) show
line-feed
(  0.170 secs.) show
line-feed
(Ghostscript Sparc2) show
line-feed
(  0.233 secs.) show
line-feed
(Ghostscript 286-12MHZ) show
line-feed
(  1.070 secs.) show
line-feed
(NeWS Server V2.1) show
line-feed
(  3.000 secs.) show
line-feed
(NeWS Server V3) show
line-feed
(  5.207 secs.) show
line-feed
(QMS-PS 2210) show
line-feed
(  5.274 secs.) show
line-feed
(QMS-PS 810 Turbo) show
line-feed
(  6.989 secs.) show
line-feed
(LaserWriter II NT) show
line-feed
( 13.354 secs.) show
line-feed
(HP LaserJet IIIP) show
line-feed
( 13.605 secs.) show

showpage
} if        % do performance page
Technical Details
Message-ID: <1992Oct9.202929.25436@pixel.kodak.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!newsserver.pixel.kodak.com!kinsman

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!newsserver.pixel.kodak.com!kinsman
From: kinsman@ssd.kodak.com (Andy Kinsman 253-7794)
Subject: Here is a postscript information/benchmark program
Message-ID: <1992Oct9.202929.25436@pixel.kodak.com>
Originator: kinsman@crestone
Sender: news@pixel.kodak.com
Organization: Eastman Kodak
Date: Fri, 9 Oct 92 20:29:29 GMT
Lines: 575