|
Tests the font cache by printing the same character
set three times. Notice in the output
page how the first set takes 52840 ms, the second set
takes 2151 ms, and the third takes 1120 ms.
|
%!PS FontCache.ps by G.Garchar
% WHEN DOWNLOADED TO POSTSCRIPT PRINTER
% ILLUSTRATES HOW THE FONT CACHE SAVES TIME AFTER FIRST PRINTING
/cacheParams currentcacheparams ] def % CAPTURE BEGINNING CACHESTATUS
/cacheStatus [ cachestatus ] def % CAPTURE BEGINNING CACHESTATUS
/commandStringArray [ % TO BE EXECUTED IN MAIN
%(0 setcachelimit)
%([ 100000 123 1234 setcacheparams)
%([ 123456 0 12345 setcacheparams)
%([ 123456 12345 12345 setcacheparams)
] def
% SETTINGS
/alphabetString (!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~) def
/columnWidth 62 def
/lineLead -11 def
/pointSize 10 def
/Main {
/fontNameArray [
[ % PICK THE FONTS YOU WANT TO APPEAR ON THE PAGE
%courierFonts
helveticaFonts
timesFonts
%newFonts
%avantGardeFonts
] { aload pop } forall
%/Symbol
] def
%/fontNameArray [ /TYP3FNT3 /TYP3FNT4 ] def
70 752 moveto % TOP OF PAGE
/userTime usertime def % INITIALIZE FOR ELAPSED MILLISECONDS
/Courier-Bold pointSize selectfont (FontCache.ps)() % FILE NAME
product () (PageCnt =) statusdict /pagecount get exec % PRODUCT % PAGE COUNT
=string statusdict /printername get exec ShowStack % PRINTER NAME
NewLine NewLine NewLine cacheParams ShowParams % SHOW BEGINNING CACHE PARAMS
NewLine NewLine NewLine cacheStatus ShowStatus % SHOW BEGINNING CACHE STATUS
NewLine NewLine
commandStringArray { dup cvx exec NewLine ShowStack } forall % EXEC AND SHOW COMMAND STRINGS
NewLine (#1 ShowFonts) ShowFonts
NewLine NewLine (#2 ShowFonts) ShowFonts
NewLine NewLine (#3 ShowFonts) ShowFonts
NewLine % BOTTOM OF PAGE
NewLine NewLine currentcacheparams ] ShowParams % SHOW ENDING CACHE PARAMS
NewLine NewLine NewLine [ cachestatus ] ShowStatus % SHOW ENDING CACHE STATUS
showpage %pstack
} def
/ShowParams { gsave % STACK: ARRAY
/cacheParams exch def % TAKE IT OFF THE STACK
/Courier pointSize selectfont
()(size)(lower)(upper) ShowStack
NewLine (PARAMS:) cacheParams aload pop ShowStack
grestore
} def
/ShowStatus { gsave % STACK: ARRAY
/cacheStatus exch def % TAKE IT OFF THE STACK
/Courier pointSize selectfont
()(bSize)(bMax)(mSize)(mMax)(cSize)(cMax)(bLimit) ShowStack
NewLine (STATUS:) cacheStatus aload pop ShowStack
grestore
} def
/ShowFonts {
fontNameArray { NewLine ShowFont } forall
NewLine NewLine ShowTime
} def
/ShowFont { gsave pointSize selectfont alphabetString show grestore } def
/ShowTime { gsave
/Courier-Bold pointSize selectfont
% FIGURE ELAPSED TIME
() usertime userTime sub (milliSeconds) ShowStack
/userTime usertime def % RESET
grestore
} def
/ShowStack { gsave
count -1 1 { -1 roll dup type /integertype eq { FormatInt } if Show NewColumn } for
grestore
} def
/NewLine { 0 lineLead rmoveto } def
/NewColumn { columnWidth 0 rmoveto } def
/Show { gsave show grestore } def
/FormatInt { % STACK: INTEGER -> STRING
/stringIn exch 15 string cvs def
/theLen stringIn length def
/stringOut theLen 3 idiv theLen add string def
/theAdj 0 def % ADJUSTMENT TO INDEX AFTER COMMAS ARE INSERTED
/theIndex 0 def
/quantum theLen 3 mod def % DIGITS BEFORE COMMA
{ stringIn theIndex quantum getinterval
stringOut theIndex theAdj add 3 -1 roll putinterval
/theIndex theIndex quantum add def
theIndex theLen eq {exit} if
stringOut theIndex theAdj add (,) putinterval
/theAdj theAdj 1 add def
/quantum 3 def
} loop
stringOut (,) anchorsearch { pop } if
} bind def
% FONT ARRAYS
/avantGardeFonts [
/AvantGarde-Book
/AvantGarde-BookOblique
/AvantGarde-Demi
/AvantGarde-DemiOblique
] def
/bookmanFonts [
/Bookman-Demi
/Bookman-DemiItalic
/Bookman-Light
/Bookman-LightItalic
] def
/courierFonts [
/Courier /Courier-Bold /Courier-BoldOblique /Courier-Oblique
] def
/helveticaFonts [
/Helvetica /Helvetica-BoldOblique /Helvetica-Oblique
/Helvetica-Narrow /Helvetica-Narrow-Bold
/Helvetica-Narrow-BoldOblique /Helvetica-Narrow-Oblique
] def
/newCenturySchlbkFonts [
/NewCenturySchlbk-Bold
/NewCenturySchlbk-BoldItalic
/NewCenturySchlbk-Italic
/NewCenturySchlbk-Roman
] def
/newFonts [
%/Type0Font2 % RANGECHECK!
/Type0Font3
/Type0Font4
%/Type0Font5 % RANGECHECK!
%/Type0Font6 % RANGECHECK!
/Type0Font7
/Type0Font8
/Type1Font1
/TestFont
/Type3Font1
/Type3Font2
/TYP3FNT3
/TYP3FNT4
/Type3Font5
/Type3Font6
/Type3Font7 % NOT FOUND!
] def
/otherFonts [
/Symbol
/ZapfChancery-MediumItalic
/ZapfDingbats
] def
/palatinoFonts [
/Palatino-Bold
/Palatino-BoldItalic
/Palatino-Italic
/Palatino-Roman
] def
/timesFonts [
/Times-Bold /Times-BoldItalic /Times-Italic /Times-Roman
] def
%/TYP3FNT3 newfont definefont pop
%/TYP3FNT4 snewfont definefont pop
Main