Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Doodles · Jun 24, 2014 at 05:53 PM · performancespeed

How significant is the performance difference between a jagged array and a multidimensional array?

I've heard many times that jagged arrays tend to have better access speeds and also that multidimensional arrays usually use less memory and can be allocated more quickly but exactly how big are these differences (in terms of actual numerical figures)?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MakeCodeNow · Jun 24, 2014 at 06:58 PM

I'm sure it depends on the language, runtime, platform, etc. In something like Mono/C# the differences are probably minuscule to non-existent. If need hard data, you should write a test yourself in your target environment, as other people's tests are not guaranteed to be identical. Ultimately, the choice in representation should be made based on which is a more natural expression of the functional logic. Don't worry about minuscule performance differences like this until they show up in a profiler (which they probably will not).

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Doodles · Jun 25, 2014 at 12:44 AM 0
Share

I did a few tests on my own and you seem to be right, there is usually very little difference between jagged and multidimensional arrays.

avatar image Bunny83 · Jun 25, 2014 at 01:12 AM 0
Share

When it comes to access speed multidimensional arrays should be faster as the offset can be calculated directly. Jagged arrays you have to get the reference of the next inner array first before you can index the next dimension.

Jagged arrays have a slightly larger memory footprint in total but what most forget is that multidimensional arrays need 1 continuous block of memory while a jagged array is split up into smaller chunks of memory. If your memory is already heavily fragmented the creation of a multidimensional array might take a while or will completely fail.

It depends on the desired size and usage which one is better.

@$$anonymous$$akeCodeNow:
Since we talk about Unity the language is irrelevant since Unity only uses $$anonymous$$ono, on all platforms. On some platforms the implementation of $$anonymous$$ono might be different but that shouldn't make a big difference. It's more likely that the overall performance and memory size will make a difference.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

RigidBodies vs CapsuleCasts 0 Answers

Scripting performance questions (JS) 0 Answers

Pros and Cons of Lightmapping 1 Answer

What's a good method for measuring shader performance? 0 Answers

Objects moving slowly in preview. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges