* * *

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

schuler

  • Jr. Member
  • **
  • Posts: 89
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:

https://www.freepascal.org/docs-html/rtl/classes/tstringlist.html

ASBzone

  • Jr. Member
  • **
  • Posts: 63
  • 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)
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 (32-bit) + FPC 3.0.4
Windows 10 Pro x64, Version 1803 (Build 17134.5)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...)

graemejc

  • New member
  • *
  • Posts: 17
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:

https://www.freepascal.org/docs-html/rtl/classes/tstringlist.html

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.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus