which is better small relation db query or constant global variable interaction?
I am building a web application where i am using multilingual support. I am using variables for label text display, so that administrators can change a value in one place and that change is reflected throughout the application.
Please suggest which is better/less time consuming for displaying label text?
- using relational db interaction.
- constant variable.
- xml interaction.
How could I find/calculate the processing time of the above thre开发者_如何学编程e?
'Less time Consuming' is easy, and completely intuitive; constants will always be faster than retrieving the information from any external source, even another in-memory source. Probably even faster than retrieving it from a variable (which is where any of the other solutions would have to end up putting the data)
But I suspect there is more to it than that. If you need to support the ability to change that data (and even if not), you may consider also using Resource Files, which would enable you to replace all such resources based on language/culture.
But you could test the speed fairly easily using the .NET 4 StopWatch
class, or the system tickcount (not sure of the object offhand where that comes from) if you don't have 4.0
db interaction, in that case the rate of db-interaction would be increased, unless you apply some cache logic.
Constants, Manageability issues.
XML, parsing time+High rate of IO etc.
Create three unit test for each choice. Load test them and compare the results.
精彩评论