Jump to content

[SOLVED] Performance question: std::map vs. struct


HughJanus
 Share

Recommended Posts

So SAC and I were discussing performance and pretty code via DM and the question came up wheter a lot of maps or a single map filled with structs with lots of attributes would be more performant.

Since we didnt know, I wanted to search some knowledge here.

Will a script be more performant if I use e.g. 100 std::maps to store and retrieve information for 1000 keys or one single map filled with 1000 keys, each value being a struct with 100 attributes?

Edited by HughJanus
Link to comment
Share on other sites

Let me preface my reply by saying that it is irrelevant in comparison to the performance cost of other operations, such as making native calls.

 

However, the cost of performing map lookup in comparison with a dereferencing a pointer is a lot greater, so a single map with lots of values would be faster. But again, we are talking infinitesimal differences. The degree of organization a single map provides is also worth a lot.

  • Like 1
Link to comment
Share on other sites

  • HughJanus changed the title to [SOLVED] Performance question: std::map vs. struct

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...