Author Topic: Dynamic arrays ...  (Read 4449 times)


  • Jr. Member
  • **
  • Posts: 98
Re: Dynamic arrays ...
« Reply #15 on: June 13, 2018, 05:17:52 am »
Hi Graemejc,
Having a look at TStringList might be a good idea:


  • Full Member
  • ***
  • Posts: 225
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Dynamic arrays ...
« Reply #16 on: June 17, 2018, 11:34:30 pm »
In my application I am copying large amounts of floats, some 50 million values or  more, from one array to another, performing a simple filter operation; for instance, values outside a certain range are discarded. The target array will therefore be smaller than the original. I started with incrementing the size with each new element copied across, but that became very noticeably slower as the target array grew in size. Blockwise allocation speeded it up quite significantly.

I tested prime numbers up to 50,000,000 and finally saw a measurable difference in performance between pre-allocating the array size to the max likely number...

By the time we get to 50 million (which brings us into the millions of prime numbers), I saw a difference of 5 seconds between starting the array at full size, and starting at 25 elements and growing as needed.    8)

Lazarus v2.0.3 r61198 / FPC v3.2.0-beta-r42126 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.116)
Other Systems: Windows 10 Pro x64, Version 1809 or greater


  • New member
  • *
  • Posts: 25
Re: Dynamic arrays ...
« Reply #17 on: June 20, 2018, 02:59:46 am »
Hi Graemejc,
Having a look at TStringList might be a good idea:

Thanks. Undoubtedly I will try to get to object oriented programming eventually. I did a thesis on OOP in 1989 then left the profession completely (stupid, I know), so I'm just trying to re-acquaint myself with the simple stuff before moving onto OOP. At the moment, I'd be lucky to be able to put in 5-6 hours per week on programming, so it'll be a slow learning curve.