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

  • Home
  • SEARCH
  • 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 882995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:30:52+00:00 2026-05-15T12:30:52+00:00

I just got a code handed over to me. The code is written in

  • 0

I just got a code handed over to me. The code is written in C# and it inserts realtime data into database every second. The data is accumulated in time which makes the numbers big.

The data is updated within the second many times then at the end of the second result is taken and inserted.

We used to address the dataset rows directly within the second through the properties. For example many operations like this one ‘datavaluerow.meanvalue += mean; could take place.
we figured out that this is degrading the performance after running the profiler becuase of the internal casting done so we created 2d array of decimals on which the updates are carried out then the values are assigned to the datarows only at the end of the second.
I ran a profiler and found out that it is still taking a lot of time (although less than the time spent accessing datarows frequently when added up).

The code that is exectued at the end of the second is as follows

public void UpdateDataRows(int tick)
{
  //ord
  //_table1Values is of type decimal[][]
  for (int i = 0; i < _table1Values.Length; i++)
  {
    _table1Values[i][(int)table1Enum.barDateTime] = tick;
    table1Row[i].ItemArray = _table1Values[i].Cast<object>().ToArray();

  }
  // this process is done for other 10 tables            
}

Is there a way to further improve this approach.

  • 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-15T12:30:53+00:00Added an answer on May 15, 2026 at 12:30 pm

    One obvious question: why do you have a 2D array of decimals when you’re only updating them with integers? Could you get away with an int[][] instead?

    Next, why are you accessing (int)table1Enum.barDateTime on each iteration? Given that there’s a conversion involved there, you may find it helps if you extract that out of the loop.

    However, I suspect the majority of the time is going to be spent in _table1Values[i].Cast<object>().ToArray(). Do you really need to do that? Taking a copy of the decimal[] (or int[]) would be faster than boxing every value on every iteration on every call – and then creating another array.

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

Sidebar

Related Questions

I got some code off the Internet and now I just need help to
I got this code from someone and it works very well, I just want
I was just running style cop against some of my code and got a
I've got this image: I want to code this image (just the bar, not
I just got a source code file from a friend. The file was created
I just got to read the following code somewhere : public class SingletonObjectDemo {
So I just got a nasty surprise when I deployed some code I thought
I just got on board with EF 5 and am using their code-first migrations
I just got my azure invitation code...yay! Are there any official samples for windows
I just got the code for the new like button (the one that also

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.