My.Settings question

Kane Jeeves

Active member
Joined
May 17, 2006
Messages
44
Programming Experience
5-10
Does anyone know if my.settings values are loaded at runtime? Or are they read from the settings file when needed? I have an app with around 100 settings, and I'd like to know if there's any benefit to loading the settings into variables vs. just grabbing them with the settings object.

Thanks!

-Kane
 
They are all loaded into a collection when first setting is needed. The time after initialization may be 0.002ms to get the variable and 0.02ms to get the setting. So in most cases the difference doesn't mean a thing, in other cases you get 10 times better performance for this particular lookup if you cache the setting in a local variable before using it in an extensive loop. I also used StopWatch for a 1000 iterations loop and found there was about a 1ms difference total.
 
So maybe...

So maybe there's a benefit in just accessing the settings, which are loaded anyways, instead of "doubling up" by having the settings in memory AND 100 variables.

Thanks for the help too!

- Kane
 
100 variables???????????
 
Yep. The app is all about user settings...numerous fonts, text settings, paths to files, etc. Right now I have them all saved in Settings, then load'em up in variables. But the app seems a bit sluggish, so I was wondering if I could do away with the doubling up.
 
I believe so. You would only cache a setting in a local variable in a method routine before using the value extensively in a loop. Use stopwatch to time any operation in question and make a decision if it's worth the hassle. Also remember there is a lot more to the Settings object than get/set value, it is a centralized storage reachable from anywhere in the application, you can use two-way binding for settings to properties on controls, and you don't have to manage change/save of values yourself.
 
Back
Top