[gambit-list] Speed improvement of lib/digest.scm
Marc Feeley
feeley at iro.umontreal.ca
Fri Feb 20 16:00:42 EST 2009
On 19-Feb-09, at 11:49 PM, Marc Feeley wrote:
> Seriously though the size (of the expanded source) comes down by a
> factor of 5 when inlining is disabled, with no loss in speed. There
> is just a slight saving in code space. Go figure! The change is now
> in the repository.
The pretty-printing algorithm is also to blame. I have now
implemented an algorithm which slides a window left and right as the
nesting increases/decreases.
In the case of digest.scm this brings down the size of the pretty-
printed expansion by a factor of 7.
The patch has been committed to the repository.
Below are a few examples.
Marc
% gsi -e "(define (f n) (if (> n 0) (list 'aaaaa 'bbbbb (f (- n 1))
'ccccc 'ddddd) 'end))(pp (f 10))"
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa
bbbbb
;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
end
ccccc
ddddd)
ccccc
ddddd)
ccccc
ddddd)
;;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ccccc
ddddd)
ccccc
ddddd)
ccccc
ddddd)
ccccc
ddddd)
ccccc
ddddd)
ccccc
ddddd)
ccccc
ddddd)
% gsi -e "(define (f n) (if (> n 0) (list 'aaaaa 'bbbbb (f (- n 1)))
'end))(pp (f 20))"
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa
bbbbb
;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
(aaaaa bbbbb
end))))))))))))))))))))
More information about the Gambit-list
mailing list