Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Jagged Arrays and Inverse
Message
From
03/01/2005 17:44:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
00973641
Message ID:
00973952
Views:
20
>>Hello Cetin,
>>>>Probably you want a multidimensional array and not a jagged array (according to benchmarks from MS jagged arrays are much slower).
>Cetin
>I found an article on the Net about Arrays : http://www.codeproject.com/dotnet/arrays.asp?
>629632&df=100&forumid=14002&exp=0
>
>I read in that Article that Jagged Array are faster than multidimensional Arrays, quote :
>
>SZARRAYS, perform so much faster than MDARRAYS, that jagged arrays,
>which are SZARRAYS containing other SZARRAYS are highly preferred
>over regular multidimensional arrays for performance. Keep in mind, that
>jagged arrays are not CLS-compliant and may not be worked cross-language.
>
>
>I'm now somewhat confused, do you have any reference to the benchmarks of Microsoft?
>
>Thank you.
>
>Zakaria al Azhar

MS PAG documentation says jagged are faster and recommends jagged arrays vs multidimensional. I think your lines are from PAG documentation.

"There is a minor limitation in the current JIT compiler regarding the graceful elimination of bound checks on rectangular arrays, hence accessing a relatively small two-dimensional jagged array sequentially (row-by-row) might be quicker than accessing a two-dimensional rectangular array on some machines. The same will not be true for larger array sizes as jagged arrays will lose more time in fetching random elements from different locations in memory. You can approximate that the performance of a jagged array is inversely proportional to the number of elements accessed when not walking linearly through each row.
Jagged arrays perform miserably in cases when elements are accessed diagonally or randomly because of their poor locality. Rectangular arrays, on the other hand, seem to perform four to five times better than jagged arrays in such scenarios."

This is from MSDN magazine, "C# in depth:Harness the Features of C# to Power Your Scientific Computing Projects". There you'd also find some more info plus benchmark graphics showing multidimensional are faster, C faster than C#, unmanaged faster than managed etc.

The way you access to elements and the data size matters in summary.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform