Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7434587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:55:02+00:00 2026-05-29T09:55:02+00:00

I have a case here that I would like to have some opinions from

  • 0

I have a case here that I would like to have some opinions from the experts 🙂

Situation:

  • I have a data structure with ´Int32´ and ´Double´ values, with a total of 108 bytes.
  • I have to process a large series of this data structure. Its something like (conceptual, I will use a for loop instead):
double result = 0;
foreach(Item item in series)
{        
    double += //some calculation based on item
}
  • I expect the size of the series to be about 10 Mb.
  • To be useful, the whole series must be processed. It’s all or nothing.
  • The series data will never change.

My requirements:

  • Memory consumption is not an issue. I think that nowadays, if the user doesn’t have a few dozen Mb free on his machine, he probably has a deeper problem.
  • Speed is a concern. I want the iteration to be as fast as possible.
  • No unmanaged code, or interop, or even unsafe.

What I would like to know

  • Implement the item data structure as a value or reference type? From what I know, value types are cheaper, but I imagine that on each iteration a copy will be made for each item if I use a value type. Is this copy faster than a heap access?
  • Any real problem if I implement the accessors as anonymous properties? I believe this will increase the footprint. But also that the getter will be inlined anyway. Can I safely assume this?
  • I’m seriously considering to create a very large static readonly array of the series directly in code (it’s rather easy do this with the data source). This would give me a 10Mb assembly. Any reason why I should avoid this?

Hope someone can give me a good opinion on this.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:55:03+00:00Added an answer on May 29, 2026 at 9:55 am

    Implement the item data structure as a value or reference type? From what I know, value types are cheaper, but I imagine that on each iteration a copy will be made for each item if I use a value type. Is this copy faster than a heap access?

    Code it both ways and profile it aggressively on real-world input. Then you’ll know exactly which one is faster.

    Any real problem if I implement the accessors as anonymous properties?

    Real problem? No.

    I believe this will increase the footprint. But also that the getter will be inlined anyway. Can I safely assume this?

    You can only safely assume things guaranteed by the spec. It’s not guaranteed by the spec.

    I’m seriously considering to create a very large static readonly array of the series directly in code (it’s rather easy do this with the data source). This would give me a 10Mb assembly. Any reason why I should avoid this?

    I think you’re probably worrying about this too much.

    I’m sorry if my answer seems dismissive. You’re asking random people on the Internet to speculate which of two things is faster. We can guess, and we might be right, but you could just code it both ways in the blink of an eye and know exactly which is faster. So, just do it?

    However, I always code for correctness, readability and maintainability at first. I establish reasonable performance requirements up front, and I see if my implementation meets them. If it does, I move on. If I need more performance from my application, I profile it to find the bottlenecks and then I start worrying.

    You’re asking about a trivial computation that takes ~10,000,000 / 108 ~= 100,000 iterations. Is this even a bottleneck in your application? Seriously, you are overthinking this. Just code it and move on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a specific case here in which I would like some security advice.
I have some data that I would like to gzip, uuencode and then print
I have to write an architecture case study but there are some things that
Here is an example feed that I would like to parse: https://gdata.youtube.com/feeds/api/users/aniBOOM/subscriptions?v=2&alt=json You can
I have a case where I have a ul li menu that I would
I have an Android app that I would like to convert to an Android
I would like to draw on a CGContext by using tiles from CGImage that
I have some tables that contain data about players and the games they have
I have a C# library that would like to have the ability to Send/Post
I have a horizontal ListView which I would like to ensure that there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.