Click here to Skip to main content
15,900,108 members
Home / Discussions / C#
   

C#

 
QuestionHow to "link" a referenced dll to a third party dll I develop. Pin
AtaChris1-May-24 8:47
AtaChris1-May-24 8:47 
AnswerRe: How to "link" a referenced dll to a third party dll I develop. Pin
Dave Kreskowiak1-May-24 10:37
mveDave Kreskowiak1-May-24 10:37 
GeneralRe: How to "link" a referenced dll to a third party dll I develop. Pin
AtaChris1-May-24 18:06
AtaChris1-May-24 18:06 
GeneralRe: How to "link" a referenced dll to a third party dll I develop. Pin
Dave Kreskowiak2-May-24 3:36
mveDave Kreskowiak2-May-24 3:36 
QuestionPerformance of Switch case vs dictionary with delegates Pin
Jörgen Andersson29-Apr-24 4:29
professionalJörgen Andersson29-Apr-24 4:29 
AnswerRe: Performance of Switch case vs dictionary with delegates Pin
trønderen29-Apr-24 5:53
trønderen29-Apr-24 5:53 
AnswerRe: Performance of Switch case vs dictionary with delegates Pin
jschell29-Apr-24 14:43
jschell29-Apr-24 14:43 
AnswerRe: Performance of Switch case vs dictionary with delegates Pin
Rob Philpott29-Apr-24 22:45
Rob Philpott29-Apr-24 22:45 
Interesting question, to which I wouldn't like to guess the answer, but here's what I'd consider.

Firstly, what is it that is being switched? If its something primitive like an integer, the switch code would I expect boil down to a collection of CMP and BEQ instructions (compare and branch). These would be stupidly fast, and because they are consecutive in memory are likely to benefit from CPU caching, so in that instance, an awful lot of switch cases could be compared in the time of a dictionary look up.

If you are switching on strings though, things get more complicated. To do the dictionary look up, first the string needs to be hashed to give a bucket index, then an equality check is needed to make sure it matches. The switch statement doesn't need to do the hash, but has multiple equality checks to do, so I suspect the answer here boils down to the ratio of time taken to hash vs. time taken to do an equality check. So then you get into the realms of how similar are the strings? To check for equality, if the first character is different you can just bail out and fail the test quickly, but if its the last you have to go through every character before you can pass or fail the test.

It'd be interesting to profile this, but somehow the idea of creating a switch statement with hundreds/thousands of cases sounds unpleasant, I have no idea whether a compiler would accept it and would be completely impossible to work with.
Regards,
Rob Philpott.

GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Jörgen Andersson29-Apr-24 23:19
professionalJörgen Andersson29-Apr-24 23:19 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Richard Deeming30-Apr-24 0:12
mveRichard Deeming30-Apr-24 0:12 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Rob Philpott30-Apr-24 0:22
Rob Philpott30-Apr-24 0:22 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Jörgen Andersson30-Apr-24 2:15
professionalJörgen Andersson30-Apr-24 2:15 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Rob Philpott30-Apr-24 0:17
Rob Philpott30-Apr-24 0:17 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Jörgen Andersson30-Apr-24 3:14
professionalJörgen Andersson30-Apr-24 3:14 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Jörgen Andersson30-Apr-24 4:22
professionalJörgen Andersson30-Apr-24 4:22 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Rob Philpott30-Apr-24 4:27
Rob Philpott30-Apr-24 4:27 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
jschell30-Apr-24 12:17
jschell30-Apr-24 12:17 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Jörgen Andersson1-May-24 8:21
professionalJörgen Andersson1-May-24 8:21 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Jörgen Andersson1-May-24 8:49
professionalJörgen Andersson1-May-24 8:49 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Richard Deeming1-May-24 21:47
mveRichard Deeming1-May-24 21:47 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
trønderen2-May-24 6:50
trønderen2-May-24 6:50 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Richard Deeming2-May-24 21:39
mveRichard Deeming2-May-24 21:39 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Rob Philpott2-May-24 23:57
Rob Philpott2-May-24 23:57 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
Richard Deeming3-May-24 0:39
mveRichard Deeming3-May-24 0:39 
GeneralRe: Performance of Switch case vs dictionary with delegates Pin
trønderen3-May-24 3:36
trønderen3-May-24 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.