Re: How much faster is Proc{} bind def with 'bind' ?



hoffmann@xxxxxxxxxxxx wrote in news:1132813731.200640.106960
@g14g2000cwa.googlegroups.com:

....
> This leads again to the question 'which part in the interpreter
> workflow consumes most of the time ?'

I suspect that the summation in the inner loop is significant.

I changed the code so that the x and y sum is not recalculated for every
vertex (rather, I keep partial X and Y sums at each loop level).
The code in your original posting + patches (DrawHilb0) ran in about
1300+ ms on G8.14 on my machine.
The code in your second posting (DrawHilb1) ran in about 930+ ms.
The code below with partial sums (DrawHilb2) rans in about 700+ ms.
Note that there is another optimization : I changed since Tx, Ty and Ti
are constant, I substituted run-time name look-up with compile-time name
lookup (//Tx, //Ty and //Ti syntax and the arrays are now outside the
loop). That brings a small speedup too.
Maybe removing more name lookup and using the stack instead may bring
some improvement (not sure, since you typically trade name lookup for
twice as much "roll" calls...)


/DrawHilb2
{
/g8 0 def
/xo 0 def
/yo 0 def
4
{/x8 //Tx g8 get 7 bitshift def
/y8 //Ty g8 get 7 bitshift def
/g7 //Ti g8 get def
/g8 g8 1 add def
4
{/x7 //Tx g7 get 6 bitshift def
/y7 //Ty g7 get 6 bitshift def
/g6 //Ti g7 get def
/g7 g7 1 add def
/X7 x8 x7 add def
/Y7 y8 y7 add def
4
{/x6 //Tx g6 get 5 bitshift def
/y6 //Ty g6 get 5 bitshift def
/g5 //Ti g6 get def
/g6 g6 1 add def
/X6 X7 x6 add def
/Y6 Y7 y6 add def
4
{/x5 //Tx g5 get 4 bitshift def
/y5 //Ty g5 get 4 bitshift def
/g4 //Ti g5 get def
/g5 g5 1 add def
/X5 X6 x5 add def
/Y5 Y6 y5 add def
4
{/x4 //Tx g4 get 3 bitshift def
/y4 //Ty g4 get 3 bitshift def
/g3 //Ti g4 get def
/g4 g4 1 add def
/X4 X5 x4 add def
/Y4 Y5 y4 add def
4
{/x3 //Tx g3 get 2 bitshift def
/y3 //Ty g3 get 2 bitshift def
/g2 //Ti g3 get def
/g3 g3 1 add def
/X3 X4 x3 add def
/Y3 Y4 y3 add def
4
{/x2 //Tx g2 get 1 bitshift def
/y2 //Ty g2 get 1 bitshift def
/g1 //Ti g2 get def
/g2 g2 1 add def
/X2 X3 x2 add def
/Y2 Y3 y2 add def
4
{/x1 //Tx g1 get def
/y1 //Ty g1 get def
/g1 g1 1 add def

/xn x1 X2 add def
/yn y1 Y2 add def

xo yo moveto xn yn lineto stroke
/xo xn def
/yo yn def

} repeat % 1
} repeat % 2
} repeat % 3
} repeat % 4
} repeat % 5
} repeat % 6
} repeat % 7
} repeat % 8
} bind def

_______________________________________________________
François Robert
(to mail me, reverse character order in reply address)
.



Relevant Pages


Loading