views:

41

answers:

2

As a follow up question to this one I asked yesterday, are there any good resources for finding the expected, worst case, or best case runtimes of the various c# builtin methods?

Again, I am not looking for a search engine. When developing software, an API is useful, but it seems that that API should also include a runtime promise.

A: 

When I need to get an idea of what is going on, I often use Reflector. Even though it does not provide any timings as such, reading the code will give you an idea of its performance.

norheim.se
A: 

When you say runtimes, do you mean execution time? Based on your previous question, are you want to know things like a call to GetType() for example? If so, that would be difficult since the execution time of a function is dependent many things, least of which would be the hardware that it is running on and of course to the data passed to the function.

Of course for algorithms there is big-O notation (complexity) of the algorithm. Which can be used as a guideline to selecting the most appropriate algorithm for a specific problem. For example adding an item to a linked list is an O(1) operation, where searcing a linked list for an item is an O(n) operation where n relates to the number of items in the linked list, but a hash table lookup is again an O(1) operation etc. etc.

Chris Taylor
Right. This is what I would like to know for all the methods that come prepackaged for C#.
For the common data structures that .NET implements, you can expect performance based on their textbook definitions. Like Dictionary has O(1) retrieval time.
Jerome
@user420667, in some cases the MSDN does include this info, for example the SortedList includes the Big-O for the various operations in the remarks section. But I am still confused when you say all the methods, are you refering to all the methods on the collection classes or each and every method for every class, like the Type class for example?
Chris Taylor
Hm... I hadn't noticed that about the Collections classes, but thanks bringing it to my attention. Actually I had been talking about ALL methods, but the classes in Collections is a good start.