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 8113869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:58:16+00:00 2026-06-06T02:58:16+00:00

I have the following code: // Dictionary which I want to optimize Dictionary<string, MyClass>

  • 0

I have the following code:

// Dictionary which I want to optimize
Dictionary<string, MyClass> myDict;
//
Dictionary<int, KKSKey> kksKeyList;

...    
...
...

// Classes
[Serializable]
public class MyClass : MyBaseClass
{
    Dictionary<int, DebugValue> myDebugValues;    
    ...
    ...
    ...
}

//
[Serializable]
public class DebugValue
{
    public int ValueType {get;set;}
    public double Value {get;set;}
    ...
    ...
    ...
}

public class KKSKey
{
    public string KKS { set; get; }
    public string Variable { set; get; }
    ...
    ...
    ...
}

The reason I used dictionaries everywhere is because I need to access the lists by a key.

I have the following lines in a for loop that runs just over 550,000 (yes!) times. myDict has about 10,000 items and kksKeyList has over 550,000 items.

Each of the following lines runs for i = 0 to 550,000:

myDict[kksKeyList[i].KKS].myDebugValues[i].ValueType = DOUBLE;
myDict[kksKeyList[i].KKS].myDebugValues[i].Value = tempdouble;

Basically, the above lines are filling up the dictionary items with raw data received over TCP. Each one of the above line takes about 90-100 milliseconds per for loop (550,000 times). This is not acceptable for my application. It must complete one of above lines within 50 milliseconds. Can anyone suggest how to optimize the performance of above operation? I am open to any suggestions, even if it means redefining the related classes if necessary.

  • 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-06-06T02:58:17+00:00Added an answer on June 6, 2026 at 2:58 am

    You can try:

    string kks = kksKeyList[i].KKS;
    myDict[kks].myDebugValues[i].ValueType = DOUBLE;
    myDict[kks].myDebugValues[i].Value = tempdouble;
    

    or maybe:

    myDict[kksKeyList[i].KKS] = new DebugValue(DOUBLE, tempdouble)
    

    If it suits your constructor…

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

Sidebar

Related Questions

I have the following code: public static class ScraperMasterUriDetails { public static Dictionary<Guid, string>
I have the following code: private Dictionary<int, Entity> m_allEntities; private Dictionary<Entity, List<IComponent>> m_entityComponents; public
I have the following code which produces a dictionary containing multiple lists; each list
So I have the following code, and I want to know which is considered
I have the following code in C# that returns a Dictionary<string, List<Discount>> . static
I have a Dictionary bound to DataGridView by using following sample code. DataGridView bound
I have the following code set up in my Startup IDictionary<string, string> properties =
I have the following code which lets me execute a workflow. This could be
i have the following code which walks through an Excel file and this works
I have the following code which creates a dynamic object that is assigned to

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.