c# - Calling a method on an object a bunch of times versus constructing an object a bunch of times -


I have a list that is my data and I want to add a special method (some function) to each element in the list I want to apply Calling a method through the creator of an object is slowing down while calling the same method several times to make the same thing immediately?

In other words, it is:

 for  (int i = 0; i  

is slower than:

  myClass someObject = new myClass (); (Int i = 0; i & lt; myData.Count; i ++) for some objects. SomeFunction (myData [i]); 

?

? ">

Your process of working from an earlier perspective can be a significant increase, it can also put memory pressure on Windows, so that other apps can be swapped on the disk.

Also This CLR will put a lot of pressure on the garbage collector, because each new object you make should be tracked to collect.

It will be slow, size and the number of objects you are making A lot depends on your reputation.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -