Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do you profile postscript code?

57 views
Skip to first unread message

luser- -droog

unread,
Aug 30, 2013, 2:37:08 AM8/30/13
to
I posted a sorting function a few days ago. And a few others followed.
I think it'd be fun to run these against each other. But what little
profiling I've done has been on C code with the help of gprof, which is
pretty automatic. I've read about how to do it, of course. You want to
do lots of reps to "fly over the bumps" of system-load issues.

PS offers `usertime` and `realtime`. In my experience, the numbers reported
by ghostscript's usertime weren't what I expected (though I don't remember
the details).

So, anybody know how to do it with postscript?

luser- -droog

unread,
Aug 31, 2013, 8:55:39 PM8/31/13
to
Well, here's a beginning. This code can count invocations of operators.

%!

/logdict 1 dict def

/countname { %name
logdict 1 index known {
logdict exch
logdict 1 index get
1 add put
}{
logdict exch 1 put
} ifelse
} bind def

/logname { %name
logdict 1 index 0 put
[ 1 index /countname cvx 1 index load
dup xcheck 1 index type /arraytype eq and
{ /exec cvx } if
] cvx def
} bind def

1 dict begin

/add logname
/sub logname
/mul logname
/div logname

0 [ 0 1 20{}for ] { add } forall
[ 1 1 5{}for ] { mul } forall
[ 23 -2 4{}for ] { sub } forall

1 1 add

div =

logdict { exch =only( )=only == } forall

%eof

Output:

GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
12530.0
add 22
sub 10
mul 5
div 1
GS>

luser- -droog

unread,
Sep 12, 2013, 12:40:40 PM9/12/13
to
On Friday, August 30, 2013 1:37:08 AM UTC-5, luser- -droog wrote:
Found this guide to profiling:

http://movementarian.org/linux-profiling/index.html

John Deubert

unread,
Sep 27, 2013, 10:36:54 AM9/27/13
to
The May 2003 issue of the Acumen Journal (#25) describes the
implementation of a PostScript profiler; the article's title is "A
PostScript Profiler (Sort of)."

The Journal is free for the downloading at

www.http://acumentraining.com/acumenjournal.html

Hope that helps.

- John

--
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

0 new messages