Post Reply 
Programming puzzles: processing lists!
02-13-2019, 01:30 PM
Post: #269
RE: Programming puzzles: processing lists!
Nice!

----

Time ago, in this thread or the ListExt thread (or in the little explorations thread) we talked about how slow the expansion of lists is in RPL.

Then I asked "ok, what about we go modifying preallocated lists" and DavidM from his huge experience said that there wouldn't be much of a difference, as list have still to be exploded, copied and so on.

Today I finally decided to test the question (as with computers we are often fortunate that we can test assertions if we have enough time).

This because a recent program on mine based on long lists (1000+ elements) is pretty slow even on the emulator (as the real 50g is already busy). So the question arose again "should I avoid expanding lists?".

Here the results saved also in http://www.wiki4hp.com/doku.php?id=rpl:start

Code:

  @##########################################################################​###
  @#
  @#
  @#
  @ some expanding data structures speed test
  @ as expanding lists is costly
  
  gpListExp
  \<< @on an emu48 emulator on a pentium M 1.73ghz , 741 seconds. Woah.
    \<< @always expand a list
      {}
      1 1000
      FOR lvK
        lvK +
      NEXT
    \>>
    TEVAL
    "listExp"
  \>>
  
  gpListRepl
  \<< @on an emu48 emulator on a pentium M 1.73ghz , 917 seconds. Woah.
    \<< @preallocate list and replace elements
      0 1000 NDUPN \->LIST
      1 1000
      FOR lvK
        lvK lvK PUT
      NEXT
    \>>
    TEVAL
    "listRepl"
  \>>
  
  gpVectRepl
  \<< @on an emu48 emulator on a pentium M 1.73ghz , 11.43 seconds. that's fast
    \<< @preallocate list and replace elements
      0 1000 NDUPN \->ARRY
      1 1000
      FOR lvK
        lvK lvK PUT
      NEXT
    \>>
    TEVAL
    "vectRepl"
  \>>

I cannot believe the speed on pre allocated arrays (I didn't find a way to expand them without exploding them).

I know that they are less flexible than lists, but from 740 seconds to 11 seconds, woah. I contemplated the journey of exploring what I can do using vectors (and matrices?) but I pushed it aside as with lists there are so many commands.

Likely now I have to go searching or devising functions that works on vectors especially if I use mostly numerical values. Then I can still employ list of vectors.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - pier4r - 02-13-2019 01:30 PM



User(s) browsing this thread: 2 Guest(s)