|
A couple more,
- the result goes nowhere. Apparently it worked, but it's dangerous (operation could be discarded, and really they should have been, so I have a sneaking suspicion it might have been run while suppressing JIT-optimization).
- the whole thing is only done once. The worst part of that is the JIT-compilation, but there is also "turbo lag" (part of the first loop could run at a lower frequency), other start-up nonsense (extra cache misses and so on), and a semi-random number of context switches.
- from these benchmarks, it's impossible to tell how much of the time taken is due to the loop overhead.
- it's measuring a throughput but kind of implying it's a latency.
|
|
|
|
|
Thank you, Harold! I got the first points but I don't see how he's implying that it's a latency - can you elaborate on that?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Well, he doesn't really come right out and say it, but the way he puts things makes it look like it's about latency. Things like "worth the extra ticks" or "takes x ticks", none of it is actually wrong but I just get that vague sense that he doesn't really make the distinctions between how long something takes and how often you can do it in a unit of time.
|
|
|
|
|
Ah, alright. I thought I should be able to see that in the code Thank you, Harold.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
string MyString = null;
bool isEmpty = (MyString == ""); What do you think the result of this little test is? (Slightly non-intuitive if you expect this to blow up because MyString is null).
string MyString = " ";
bool isEmpty = string.IsNullOrEmpty(MyString); Okay, is this an empty string? This is a common test to see if a user has entered some details - a space generally isn't considered true for entering details. We can dispense with the last two examples by using the same MyString = null assignment. Because it's null, neither will work so you'd have to issue a null check beforehand anyway.
By omission, you can guess which my favourite is.
|
|
|
|
|
I'm in the same camp.. I like IsNullOrEmpty because it's really all you need.
If it's not broken, fix it until it is
|
|
|
|
|
Ahem - my camp is strictly in the IsNullOrWhitespace field. I've pitched my tent, put on the gas stove and am boiling up a brew.
|
|
|
|
|
Pete O'Hanlon wrote: I've pitched my tent, put on the gas stove and am boiling up a brew
Ahem, what about the biscuits?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I expect my visitors will bring the Rich Tea.
|
|
|
|
|
I've got some Chocolate Hobnobs if you've got any coffee?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You're on. You can't beat your chocolate hobnob. Well, not in a crowded campsite field anyway.
|
|
|
|
|
Gentlemen I present, custard creams.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
All are different functions but doing almost same work.So my choice better to use IsNullOrEmpty() as its safe and performance is good as compare to IsNullOrWhiteSpace().As IsNullOrWhiteSpace()can be removed if you are not using Unicode data.Apart from that other functions Equals and Length check functions having some performance issues in large projects.
So I prefer ISNullOrEmpty() in many situation.
At last its depend upopn the code what it needs.
Thanks.
|
|
|
|
|
You do know that IsNullOrEmpty IS NOT the same as IsNullOrWhitespace don't you? If I were to paste a tab into a field, for instance, and I'm expecting it to contain a proper value, IsNullOrEmpty will let that past whereas IsNullOrWhitespace will properly identify that there's a whitespace character in there.
|
|
|
|
|
Just picking up on one specific part of your question :
Coder For Hire wrote: But do you REALLY care about TICKS???
With today's PC's and Servers running at ultra high speed, why would anyone really care?
Ah, if only...
For some usage, maybe not, but there are many application areas where performance is very important.
Modern servers may be high performance, but if you're getting Google or Amazon rate hits, then your users might start to notice a slow-down.
Gamers are also very critical of poor performance, and will notice if your refresh rate is too slow or, worse, not consistent. Been there, done that, and sometimes you work hard to squeeze out the last ounce of performance from a system.
And there are a lot of systems out there running on lower-spec hardware, especially in the embedded world, and every cycle counts in those apps. Currently there and doing that - and again, you can't afford to waste any resources, processor, memory or I/O.
Of course, I would very much hope that in any time-critical or mission-critical application, string comparisons were kept to an absolute minimum, but I have occasionally seen some coding horrors and "stringly typed" (to borrow a friend's phrase) parameters...
Days spent at sea are not deducted from one's alloted span - Phoenician proverb
|
|
|
|
|
modified 28-Jan-19 5:55am.
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Perhaps if you try to describe this as if to your mother over the phone?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Message Closed
modified 28-Jan-19 5:54am.
|
|
|
|
|
Member 11484624 wrote: first of all u can tell me nicely not like that because i ve said aouch whe i read ur replay to me .
I'm guessing from that that I have offended you - if so, I apologize; that was not the intention. The intention was to let you know in simple, easy-to-translate-via-Google terms that we need fuller information, but that without seeing your screen or knowing anything about the context of your question it's best to try explaining as if to a non-technical person with whom you are familiar: hence your mother.
The end of your sentence however makes no sense to me at all: please stop using text abbreviations - you have a full keyboard, use it.
The rest of your message still doesn't help us to know what your code is like - and without that we can;t give you specific answers. Think of it as when your car breaks down: if you ring the garage ans say "it broke" and put the phone down they aren't going to rush to where you are and fix it because they don't know:
1) Who you are.
2) What make or model of car it is.
3) Where the car is.
4) What has broken.
5) What equipment or parts they need to bring.
We are in the same situation: all we know is that you have a C# service that sends you notices. How you receive them, where your app is, how you store them, etc., we do not know - because we can't see your screen, access your HDD, or read your mind! We have no idea of the context behind your question - we just get exactly what you type to work from.
So try again, and pretend you know nothing about your project - what do you need to tell yourself so you understand!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Message Closed
modified 28-Jan-19 5:54am.
|
|
|
|
|
I know you know your project well - but we don't!
Let's turn it round for a moment: This is a modification ticket from one of my apps:
When adding a Video or Serial name, replace "’" with "'" - they are visually similar, but do not match for searching (Database integrity update required to fix existing examples). An "update application" has been created to do this correction in existing examples - ask for DBIntegrityUpdater.EXE
Now, I know what that means - because I know my project - but can you tell me exactly what I should do to implement it? And where?
Of course you can't - you have no idea even of how many layers are involved, much less which layer contains the relevant code because you have no context for the project and there are literally thousands of different ways it could have been implemented. We have the same difficulty with yours - we have no idea how your project works at the moment, so all we are asking for is the information we need!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It sounds like you need a separate method that you call beforehand to see if there are any outstanding items to pull down, then only issue your call to pull the full details down if this is empty. I'm not sure what you need help with here as this seems to be an extremely simple thing to do.
|
|
|
|
|
Message Closed
modified 28-Jan-19 5:54am.
|
|
|
|
|
I'm not replying like I'm superior to you. I'm replying like this because I don't know exactly what you are stuck on. However, until you can explain exactly what the problem is that you are facing, then you aren't going to get much help, no matter which site you go to for answers. Try asking a question like this on StackOverflow and see how quickly they shut it down.
What you need to do is explain exactly what you are trying to achieve, and what problem you are having doing that. Is your problem at the web service side? Where does this list of notifications come from? How is your polling done? These are questions you are going to have to explain before anyone can help you.
The bottom line - if you can't explain what problems you are having, then no one is going to be able to help you and you're just going to end up getting frustrated. As OriginalGriff has said - we can't see your computer so we don't know what code you have or what architecture you are using. We don't even know if you are using WinForms, WPF or ASP.NET.
|
|
|
|
|
As this kind of communication-problem seems to happen quite frequently, maybe it would be a good idea to look for some exemplary, well written questions here to 1) link them in "How to ask a question" and 2) link them in your/our replies to questions that can't be interpreted. Like the exemplary article linked somewhere in the article-writing-guides. I just had a quick look for showing one to the inquirer of this question but it seems they're a bit hard to find..
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|