Click here to Skip to main content
15,904,655 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
RantRe: AGOD Pin
Vivi Chellappa14-Sep-14 17:25
professionalVivi Chellappa14-Sep-14 17:25 
GeneralRe: AGOD Pin
Dave Kreskowiak14-Sep-14 7:58
mveDave Kreskowiak14-Sep-14 7:58 
QuestionAbsence of blogs on left news sites Pin
Ernst Iliov Stavro Blofeld13-Sep-14 12:54
Ernst Iliov Stavro Blofeld13-Sep-14 12:54 
AnswerRe: Absence of blogs on left news sites Pin
Nelek13-Sep-14 14:15
protectorNelek13-Sep-14 14:15 
AnswerRe: Absence of blogs on left news sites Pin
PJ Arends13-Sep-14 17:16
professionalPJ Arends13-Sep-14 17:16 
AnswerRe: Absence of blogs on left news sites Pin
Richard MacCutchan14-Sep-14 0:12
mveRichard MacCutchan14-Sep-14 0:12 
AnswerRe: Absence of blogs on left news sites Pin
PIEBALDconsult14-Sep-14 5:36
mvePIEBALDconsult14-Sep-14 5:36 
QuestionDoes anybody really use a Profiler? Pin
SledgeHammer0113-Sep-14 12:45
SledgeHammer0113-Sep-14 12:45 
I recently posted a question: "I am trying to solve this problem. I solved it by using Solution1. I'm not happy with Solution1 because it is going to be a performance issue and I want to use Solution2 which I think will be a lot better. How do people typically implement Solution2?"

So, of course, somebody chimes in and responds: "What makes you think Solution1 is a performance issue? Don't guess. Use a profiler!"

Are you serious? LOL...

Personally, I think anybody who has been programming a while should be able to look at a block of code for a few minutes and instantly identify why it's slow. If you rely on a profiler as a crutch, you should really work on your analytical skills as I think that's a requirement to be a good software ENGINEER and not just a coder.

I dunno, maybe it's just a talent I have, but I've never used a profiler more then maybe once or twice and I've never had an issue QUICKLY optimizing the hell out of code.

For example, just the other day, a junior co-worker complained to me that he was given a simple task and he has it working, but it's taking 2.5 minutes to run. I agreed that was waaay to slow and asked him how he did it. He said it was very basic, he just did this 1 simple step. So I said, it would be a lot faster if you used this 2 step solution instead. At first, he argued with me (cuz he's really cocky) that my 2 step solution couldn't possibly be faster then his 1 step solution. I told him that my 2 step solution would blow his 1 step solution out of the water guaranteed and that it would finish "instantly". He still didn't believe me (cuz he's really, REALLY cocky). Finally, after trying more stuff that didn't work, he implemented my 2 step solution and what do you know... it came back in "0ms" vs his 1 step solution that took 2.5 minutes.

To me, optimizing code & identifying bottlenecks isn't rocket science. It's always the same:

1) move any repetitive work that's static outside the loop
2) cache objects that are expensive to create and setup
3) cache results that are expensive to calculate
4) don't use reflection in highly trafficked code
5) don't use linq in highly trafficked code
6) don't inline SQL code, use stored procs
7) don't suck down an entire database, only grab the data as you need it

Those 7 basics will generally get you at least 50% of the way towards optimized code. There are some more "advanced" concepts that'll get you the rest of the way (and there are of course some other basic things I didn't list).

I think if you use C# every day, you should know what parts of it are slow.

Also, from my limited experience with profilers, they are more of a waste of time then good. Let's say I have this:

Dictionary<Tuple<string, object>> dict;

and then I have some highly trafficked code that does:

if (dict.TryGetValue(new Tuple<string, object>("someString", 5), out result))
{
}

that's going to be really slow. A profiler is going to show you that 99% of the run time was spent in GetHashCode() and because you don't know how to think without a profiler, you'll be clueless as to what the real problem is. Which is:

1) you're new'ing up an object on every lookup
2) you should always use a simple native object as your dictionary key since compound objects are very expensive to hash (stay away from strings and guids as well).

Thoughts?
AnswerRe: Does anybody really use a Profiler? Pin
Ravi Bhavnani13-Sep-14 13:01
professionalRavi Bhavnani13-Sep-14 13:01 
GeneralRe: Does anybody really use a Profiler? Pin
SledgeHammer0113-Sep-14 13:19
SledgeHammer0113-Sep-14 13:19 
GeneralRe: Does anybody really use a Profiler? Pin
Ravi Bhavnani13-Sep-14 13:38
professionalRavi Bhavnani13-Sep-14 13:38 
GeneralRe: Does anybody really use a Profiler? Pin
SledgeHammer0113-Sep-14 14:08
SledgeHammer0113-Sep-14 14:08 
GeneralRe: Does anybody really use a Profiler? Pin
Slacker00713-Sep-14 14:54
professionalSlacker00713-Sep-14 14:54 
GeneralRe: Does anybody really use a Profiler? Pin
David Mott15-Sep-14 5:15
David Mott15-Sep-14 5:15 
AnswerRe: Does anybody really use a Profiler? Pin
Maximilien13-Sep-14 13:02
Maximilien13-Sep-14 13:02 
GeneralRe: Does anybody really use a Profiler? Pin
SledgeHammer0113-Sep-14 13:21
SledgeHammer0113-Sep-14 13:21 
AnswerRe: Does anybody really use a Profiler? PinPopular
CDP180213-Sep-14 13:24
CDP180213-Sep-14 13:24 
GeneralRe: Does anybody really use a Profiler? Pin
Ravi Bhavnani13-Sep-14 13:39
professionalRavi Bhavnani13-Sep-14 13:39 
GeneralRe: Does anybody really use a Profiler? Pin
DaveX8613-Sep-14 13:44
DaveX8613-Sep-14 13:44 
GeneralRe: Does anybody really use a Profiler? Pin
CDP180213-Sep-14 14:04
CDP180213-Sep-14 14:04 
GeneralRe: Does anybody really use a Profiler? Pin
DaveX8613-Sep-14 14:09
DaveX8613-Sep-14 14:09 
GeneralRe: Does anybody really use a Profiler? Pin
Nelek13-Sep-14 14:22
protectorNelek13-Sep-14 14:22 
GeneralRe: Does anybody really use a Profiler? Pin
SledgeHammer0113-Sep-14 14:12
SledgeHammer0113-Sep-14 14:12 
GeneralRe: Does anybody really use a Profiler? Pin
CDP180213-Sep-14 21:35
CDP180213-Sep-14 21:35 
AnswerRe: Does anybody really use a Profiler? Pin
Slacker00713-Sep-14 13:41
professionalSlacker00713-Sep-14 13:41 

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.