|
Hi All,
I'm just rewriting a core function in an application I'm working on and was wondering what peoples thoughts are on the performance side of things.
I have a set of data that lives in a DataTable , the data in this DataTable is used to separate the data into lookups based on a key/value pairs. This suggests they should be Dictionary<string,string> (which is how I have in fact coded it) there are two lookups varying in size from 22 items to 220 items and two Dictionary<string,int> lookups that keep track of matches.
All 4 Dictionary lookups are declared static in the class and if any are empty or null at object initialisation they are all initialised in a single loop over the DataTable (which is itself set up as a thread-safe singleton).
The two main lookups are going to be looped over looking for matches thousands of times in the life of the app so getting them as performance tweaked as possible is really important.
Does this sounds like a sensible approach or are there alternatives that might perform better?
All the data in the look ups are upper cased strings, I've heard that C# actually performs string comparisons quicker if both are upper cased, does this actually stand up as correct?
Would appreciate any thoughts.
Cheers,
|
|
|
|
|
Sounds OK to me.
Jammer wrote: string comparisons quicker if both are upper cased
I doubt it, though without data to back it up, plus how much of that "saved" time is wasted by performing the upperification upperization?
However, why not try passing the Dictionary a System.StringComparer.CurrentCultureIgnoreCase ?
|
|
|
|
|
|
Jammer wrote: The two main lookups are going to be looped over looking for matches
You should put whatever value you are matching on as the key in the dictionary, so that you don't have to loop through them.
A dictionary uses hash codes to quickly find items by key, so that is very much faster than looping through the data.
Jammer wrote: I've heard that C# actually performs string comparisons quicker if both are upper cased
I've never heard that. Case-sensetive culture-invariant comparison is faster than case-insensetive culture-dependent comparison, if that is what you mean.
If you use the dictionaries correctly, it will only do one or a few string comparisons to locate each item, so the speed of string comparions is hardly an issue.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: You should put whatever value you are matching on as the key in the dictionary, so that you don't have to loop through them.
Indeed, that's what I have done.
Guffa wrote: A dictionary uses hash codes to quickly find items by key, so that is very much faster than looping through the data.
Of course! Its not going to be looping as such is it.
Guffa wrote: I've never heard that. Case-sensetive culture-invariant comparison is faster than case-insensetive culture-dependent comparison, if that is what you mean.
Gotcha, thanks.
|
|
|
|
|
hallo i need to programmatically format a hard disk.
Apart from ShFormatDisk, it seems that there's a hope by using FMIFS.DLL or UNTFS.DLL.
Has anyone a piece of code to show me?
Out there there are just old broken links to sysinternals site regarding FMIFS.DLL.
Thanks in advance
modified on Friday, December 12, 2008 3:00 PM
|
|
|
|
|
Why do you want to format a disk? Are you writing a virus?
|
|
|
|
|
If he was it would be a sh*tty virus, no gain in formatting a disk. Maybe he means a removable storage device?
|
|
|
|
|
thanks for the interesting replies, it's curious that everywhere i find a thread for "hard disk formatting" there's somebody asking if it is for virusing. Sounds like if a programmer wants to write a scanner software, it is for duplicate identity cards... Evil Is Everywhere :P
BTW has anyone serious idea of how to write a function to erase an internal (no removable, no flash memory) hard disk?
|
|
|
|
|
Nah can't help you there, I can't see any possible gain at all for formatting an internal hard drive. Tasks like that should be done by a user without any programmatical assistance through any application not specifically designed for that, it can lead to accidental formats, which should be limited and not encouraged.
|
|
|
|
|
|
Thanks Uwe. Yes i tried, they mainly suggest ShFormatDisk.
I'm trying to give my end users/customers a clean restore environment without dos boxes and nags, using imagex, but i need to format the disk before applying an image.
|
|
|
|
|
solved: i launch a command line Process with FORMAT using /Y, an undocumented flag for the unattended mode
|
|
|
|
|
Hi
Is there any possibility that I could cast an object through its handle.
For example, I have to do an estimation of objects and finally I get the handle of that object through GetWindow API call, now I know its type but how to retrieve that object and cast it for that specific type?
I am implementing it using a dll file.
Regards,
Mujtaba Panjwani
Tiger Softwares
Software Designer and Developer
VB.NET, C#, ASP.NET, VFP
|
|
|
|
|
What kind of handle - an HWND?
If so, there is no built in association between an HWND and an object.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
Thanks for the reply.
Yes, it is an HWND. To make it more clearer, the handle is of a IE's statusbar32 object, for which I know only the handle, now I want to manipulate its objects and add/remove other Microsoft Common Controls so I was thinking of a way to cast that object to comctl's statusbarclass and then manipulate it instead of throwing Messages and creating pane window etc. using API calls as I am not very good in that.
Hope I was clearer to specify my scenario and you would have the solution to it.
Regards,
Mujtaba Panjwani
Tiger Softwares
Software Designer and Developer
VB.NET, C#, ASP.NET, VFP
|
|
|
|
|
MAP Tiger wrote: I know only the handle, now I want to manipulate its objects
You'll have to use APIs unless there's some other programming model
built into IE, which I wouldn't know
Mark
.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
AFAIK, you cannot do that. The best you can do is send messages to that handle. The object doesn't exist in the managed environment, so there's no way to cast it to be a managed object.
|
|
|
|
|
Hi
Thanks for the reply. Actually I already considered that but that seems very complicated as I am willing to create another control and append it to the control whose handle is known to me. i.e. add label control into statusbar control of IE.
I hope you have a solution to this.
Regards,
Mujtaba Panjwani
Tiger Softwares
Software Designer and Developer
VB.NET, C#, ASP.NET, VFP
|
|
|
|
|
There is no way to cast that handle to an object, .NET managed, COM, or otherwise. AFAIK, IE doesn't expose any method to do what you want.
|
|
|
|
|
Hello,
I'm trying to figure out how to display lines of text with more than one color. Seems like anytime I want to change text color for a word in a string, I can't, because all the text changes to that color.
If you need an example, consider something like AOL Instant Messenger. The person sending the message has their name in one color, and the receiver has a differently colored name.
Can the standard Textbox control pull this off? Short of that, is there some kind of custom control that can do this operation?
Thanks,
Michael Fritzius
|
|
|
|
|
|
I love one-liners. This was exactly what I was looking for.
Now to dissect it and toss the rest <evilsmiley>
Thanka you,
Michael Fritzius
|
|
|
|
|
Hi all:
I met a problem about communication between a Buisness layer and UI layer in a three-tier application.
In my project the UI layer invoke a method in Business layer named DoSomething(), DoSomething() method need to finish three tasks: (1)read data from database. (2)handle these data. (3)write them to excel file. However sometimes it need interact with the customer according to the data in step (2), so I should notify the UI layer to create related interation window. Here comes the question: how should I pass the message to UI layer?
One way to solve this problem is to use delegate, but if I use delegate I should know the method need to be invoked in UI layer first, that reqire Buisness layer import the UI layer dll, but you know that disobeys the import rule of a three-tier application.
What I need is the Business layer notify the UI layer: here we need the interaction with customer, just notify.
Can some one tell me the way to solve this question? Thanks.
|
|
|
|