Static vs Dynamic Array

I am using XE2.

I use a 2 dimension static array for some calculations. It is dynamically allocated with getmem. I reference it 
with the subscript [Col * NumRows + Row]. 

Would i get better performance using a dynamic array and referencing it with [Col, Row]?

Or is it 6 of one vs a half dozen of the other?
0
Ken
12/5/2011 11:18:08 PM
embarcadero.delphi.rtl 934 articles. 0 followers. Follow

2 Replies
601 Views

Similar Articles

[PageSpeed] 40

"Ken Bailey" wrote in message news:426794@forums.embarcadero.com...
>
> I use a 2 dimension static array for some calculations. It is dynamically 
> allocated with getmem. I reference it
> with the subscript [Col * NumRows + Row].
>
> Would i get better performance using a dynamic array and referencing it 
> with [Col, Row]?
>
> Or is it 6 of one vs a half dozen of the other?


The latter. In fact, being a single block of memory accessed via a single 
subscript is going to be *at least* as fast. A 2-dim. dynamic array would be 
a set of pointers to separate arrays, and  accessing it would be more 
indirect, although that is probably taken care of at compile time.

-- 
Wayne Niddery (TeamB)
"'Thank you, Occupy Wall Street. With your vivid example of anticapitalist 
squalor, I've been able to convince all three of my children to become 
investment bankers"  - P. J. O’Rourke
0
Wayne
12/5/2011 11:44:53 PM
Thanks.
0
Ken
12/6/2011 7:45:32 PM
Reply:

Similar Artilces:

Static vs Dynamic arrays
Hi all, Just a quick query - which is better, in terms of speed and memory usage: a static or a dynamic array. For example, consider data: array[0..819200] of Byte; where we might only use 9760 bytes on some occasions, but may use the full 819200 on others, or: data: array of Byte; and then SetLength(data,9760) or SetLength(data,819200)...or any other size, depending on the size of the file being loaded. I know these days, 800KB in nothing (when most PCs have in excess of 1GB of RAM). Cheers, Gerald. Firstly, 0..819200 is 819201 bytes - there save you a by...

Static vs Dynamic arrays
Hi all, Just a quick query - which is better, in terms of speed and memory usage: a static or a dynamic array. For example, consider data: array[0..819200] of Byte; where we might only use 9760 bytes on some occasions, but may use the full 819200 on others, or: data: array of Byte; and then SetLength(data,9760) or SetLength(data,819200)...or any other size, depending on the size of the file being loaded. I know these days, 800KB in nothing (when most PCs have in excess of 1GB of RAM). Cheers, Gerald. Firstly, 0..819200 is 819201 bytes - there save you a by...

Dynamic Arrays / Static Arrays
If I call SetLength on a dynamic array, does it become more or less a static array? In use is there much difference between a dynamic and a static array? The reason I ask is becaue I don't seem to have had much use for dynamic arrays in what I've created in the past but due to a change of approach in one program I now need to declare an array without knowing how many elements it will have. In the previous incarnation I always knew in advance that the array would have 15 elements. I don't know why I've not had to ask this question before, but as usual, when I do have to...

Confusion on @array vs $array[] vs $array
--=_FCA3CF00.8EEF86D1 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello: I have been fairly confused on the intermixing of array naming standards. If I understand correctly, the @array syntaxt is used to refer to the whole array, while $array[n] is refered to specific elements. In my thinking, it would have been less confusing to use @array[n] to address specific elements, but Perl complaines bitterly when warnings &/or strict is enabled. Is the rational for the "$"array[] character for identifying ...

AllocMem vs Dynamic Array Speed Test (see .Delphi.General)
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_3c5a0.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" --JivePart=_3c5a0.zeB8CwDOH5aMJzMl Content-Type: application/zip; name="AllocMem Speed Test.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="AllocMem Speed Test.zip" UEsDBBQAAAAIACxKyDybs5DTnQAAAAwBAAANAAAAU3BlZWRUZXN0LmRwcmVOSwrCMBDdB3KHWQhV KTmAxYUIBRci1FxgascSbNMwSTeW3t3GRakWZvF+83iOu5qxhbsjqjT5k...

problem with dynamic array of dynamic array
var a:array of array of integer; begin setlength(a,2); setlength(a[0],1); setlength(a[1],2); a[0,0]:=1; //it is ok a[0,1]:=2; //it is not ok in my understanding a[0,1]:=2 is not ok because a[0] has only one element as i declared setlength(a[0],1) so i dont understand why this code exemple is compiled and run just fine ? > {quote:title=Yossi Rozenberg wrote:}{quote} > in my understanding a[0,1]:=2 is not ok because a[0] has only one element as i declared setlength(a[0],1) so i dont understand why this code exemple is compiled and run just fine ? By default, acces...

dynamic vs static
dynamc word wrap seems to be exactly like word wrap in windows's notepad. what does static warp do? I didnt see a difference when i turned static on? -- diablo1 ------------------------------------------------------------------------ On 2011-12-22 10:36, diablo1 wrote: > > dynamc word wrap seems to be exactly like word wrap in windows's > notepad. what does static warp do? I didnt see a difference when i > turned static on? On what program? -- Cheers / Saludos, Carlos E. R. (from 11.4 x86_64 "Celadon" at Telcontar) diab...

MOVED: problem with dynamic array of dynamic array
Moved to: embarcadero.public.delphi.language.delphi.general or: https://forums.embarcadero.com/thread.jspa?threadID=57076 -- Rudy Velthuis Rudin's Law: In a crisis that forces a choice to be made among alternative courses of action, people tend to choose the worst possible course. ...

C# 2.0 what is a static varaible ; static varaible vs application object ; static vs session
Hi everyone, Can anybody give me a clear picture/ suggest me good article / documetation  about the STATIC variable and their  advantages -disadvantages and usage..difference between STATIC variable and APPLICATION objdifference between STATIC variable and SESSION obj  THANKS IN ADVANCE..........   ...

static vs dynamic groups
i currently have a mix of static and dynamic groups. my dynamic groups return fairly large sets around 80,000 but are rarely used and not time sensitive--ie building a mail distribution list. i am now having some applications that insist on checking group membership for the same large population. i know static groups will be much faster which is important in logins. is the only limitation on static group list the management of them? thanks. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 As far as I know, yes. The direct tradeoff is performance for management ease (as always, rig...

static vs dynamic build ??
Under OS/2 is there an advantage to having the dynamic builds vs. static builds? Some of the dll's don't seem to be shared anyway so is there an advantage to having them broken out into dll's as opposed to a larger exe file? Andy Andy Willis wrote: > Under OS/2 is there an advantage to having the dynamic builds vs. static > builds? Some of the dll's don't seem to be shared anyway so is there an > advantage to having them broken out into dll's as opposed to a larger > exe file? No simple answer. In the case of the Moz suite, the dll's...

Static Vs Dynamic WebPart
Can someone explain the difference between a static and a dynamic webpart? Also, when would I use the:WebPartManager.AddWebPart() as opposed toInternals.AddWebPart()  Static Web Parts A Web Part zone typically contains one or two Web Parts. However, Web Parts do not have to be placed into a zone on the Web Part Page. Web Parts that are placed outside of a Web Part zone are called static Web Parts because they are treated and act just like a standard Web control. A static Web Part and its properties are stored within the Web Part Page (.aspx) file. Because of this, a user cannot ...

static vs dynamic linkbutton
I have a situation where I am auto-generating controls based on a database output and user selection.  For each new item chosen by the user, a set of labels and a linkbutton is created.  The linkbuttons are used for clearing a row of the labels.  For example, if the user clicks the linkbutton on the 3rd row, that row should get cleared out by deleting whatever is in the viewstate.  I also have a set of static labels and linkbutton that do the same thing, but these are used for storing and clearing the default values returned by the database.  The static controls...

array vs arraylist vs dropdownlist vs ListBox
I am still learning a lot about asp.net. I have code where I am loading an sqlObjectReader with multiple field records and i am looking at different ways to parse and store the records I get. So, I am thinking that I would like to use the sqlObjectReader.read method, to run through all of the records it has, and to store those records in a different object type. It looks like the dropdownlist, listbox, and arraylist only allow for me to have one item per row, which doesn' t meet what I want. Can I do this with an array ? Or, is there no easy way to add these items dynamically ...

Web resources about - Static vs Dynamic Array - embarcadero.delphi.rtl

Dynamics - Wikipedia, the free encyclopedia
Brownian dynamics , the occurrence of Langevin dynamics in the motion of particles in solution (e.g. a grain in water, as was first seen by Brown); ...

Datacenter Dynamics
Datacenterdynamics for data center information, conferences, news, videos, whitepapers and reports globally

Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find ...
Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find a Chiropractor

Paul Melville: a dynamic talent taken before his time
What might have become of a popular young cricketer with the world at his feet?

Mea Culpa: Confidence Proceedings Edition: I Really Do Think Dynamic Scoring Is a Bad Idea
... *Brad DeLong noted that when he was a Treasury political appointee, one of the Treasury career staff economists lectured me him about dynamic ...

dynamic billboards to up your photo game
NYC is one of the most photographed places in the world, especially this time of year. And while Instagram has made every one of us feel like ...

SNL perfectly captured the dynamics of the Republican presidential race
The "Saturday Night Live" recap of the latest Republican presidential debate reflected fairly accurately the state of the GOP primary. Beck ...

CES 2016 TV tech: 4K yawns, high dynamic range dawns
... Show in Las Vegas this January, TVs with 4K resolution are old hat. So what's new hat? The next-generation TV technology known as high dynamic ...

Boston Dynamics wishes you a terrifyingly happy holiday
Whether you think holiday greeting cards are touching or annoying, Boston Dynamics is celebrating the season just a little differently with this ...

Ford could challenge Uber, Lyft with Dynamic Shuttle service
... for 6 to 8 people with legroom, Wi-Fi, and no middle seats in the US and England. Up to 18 in emerging countries. Ford could run its own Dynamic ...

Resources last updated: 1/6/2016 2:14:18 AM