Very interesting and instructive, thanks!

( scratchpad ) [ testconcat ] gc benchmark [ testmake ] gc benchmark  
[ testintersperse ] gc benchmark

--- Data stack:
48568
22680
16535

On Jun 19, 2009, at 6:26 AM, Slava Pestov wrote:

> Your code still has the inefficiency of dynamic variable lookups on
> every call to , as well as resizing the underlying array of the vector
> being constructed. Here is a more direct version:
>
> : intersperse ( seq1 seq2 -- seq )
>    2dup [ length ] bi@ + <vector>
>    [ '[ [ _ push ] bi@ ] 2each ] keep
>    { } like ;
>
> Slava
>
> On Thu, Jun 18, 2009 at 3:56 AM, Phil Dawes<[email protected]> wrote:
>> I tried:
>> { 1 2 3 } { 3 2 1 } [ [ swap , , ] 2each ] { } make
>>
>> to remove the extra array creation and the concat pass. AFAICS it's
>> quicker on large arrays:
>>
>> : testmake ( -- )
>>   100000 >array dup reverse
>>   [ [ swap , , ] 2each ] { } make drop ;
>>
>> : testconcat ( -- )
>>   100000 >array dup reverse
>>   [ 2array ] 2map concat drop ;
>>
>> ( scratchpad ) [ testconcat ] gc benchmark [ testmake ] gc benchmark
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to