[plt-scheme] Making a fast list like sequence

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Tue Apr 7 19:27:06 EDT 2009

Matthew Flatt wrote:
> At Tue, 07 Apr 2009 19:09:27 -0400, David Van Horn wrote:
>> Matthew Flatt wrote:
>>> At Tue, 07 Apr 2009 18:32:33 -0400, David Van Horn wrote:
>>>> I see dramatic differences in running times between the built-in list 
>>>> sequence and a naive implementation of list sequencing.  What can I do 
>>>> to make this naive implementation run faster?
>>> If you use use `car', `cdr', and `pair? instead of `first', `rest', and
>>> `(compose not empty?)', you should get the same performance as for
>>> lists.
>> This didn't improve the running time very much.  It's still not nearly 
>> as fast as just a direct list value.
>>
>> Here are the timings for a list sequence built with car/cdr/pair?, a 
>> list-like structure sequence, a direct list, and an list in in-list:
>>
>> cpu time: 2036 real time: 2327 gc time: 0
>> cpu time: 2179 real time: 2387 gc time: 0
>> cpu time: 686 real time: 720 gc time: 0
>> cpu time: 690 real time: 694 gc time: 0
> 
> How are you running this (platform, environment, language, etc.)?
> 
> I didn't pay attention to the scale of your numbers versus mine before,
> but even in DrScheme with debugging enabled in the Module language for
> v4.1.5 on Mac OS X, I get much smaller numbers:
> 
>  cpu time: 16 real time: 16 gc time: 0
>  cpu time: 20 real time: 25 gc time: 0
>  cpu time: 22 real time: 22 gc time: 0
>  cpu time: 1 real time: 1 gc time: 0

Ah... I had profiling turned on from a while back and forgot about that.

I'm using 4.1.5.3-svn2apr2009, Module, Mac OS X, 512 mb memory limit. 
With profiling turned off, I see numbers similar to yours:

cpu time: 23 real time: 28 gc time: 0
cpu time: 30 real time: 41 gc time: 0
cpu time: 19 real time: 20 gc time: 0
cpu time: 1 real time: 1 gc time: 0

David



Posted on the users mailing list.