Recent

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

schuler

  • Full Member
  • ***
  • Posts: 223
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

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
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 v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

graemejc

  • New Member
  • *
  • Posts: 33
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.

 

TinyPortal © 2005-2018