|
I agree that when analyzing a simple block of code, a profiler is probably overkill. I've used a profiler in the past for projects written by multiple people and that have a lot of other process interactions and data coming in at different rates etc.
Profiler stats speak louder and less personally than you going and analyzing other peoples code and giving them the same feedback
|
|
|
|
|
If I was asked to review a co-workers code and he wasn't interested in my feedback unless I produced profiler outputs, charts, stats, graphs and 5 page PDF presentations, I'd consider that co-worker a douche and a waste of time and go work on something else. If my boss came and asked if I had a chance to review Bob's code, I'd simply say "Yup. I located the issue, but Bob wasn't interested in my feedback, so I went back to working on X.".
That's not a theoretical "What would you do?" . I've done that several times over my career and it generally ended very badly. For Bob.
I was a newb at a job like on my 2nd or 3rd day and I overhead Bob talking with his boss at the next cubicle about an issue that Bob had been working on for 2 weeks with no success. I was familiar with the issue since I was very strong in that area. So I politely went up to them and said "Excuse me, I couldn't help but hearing about the issue. Not to interupt or anything, but I'm certain your issue could be resolved by doing X as I have run into that issue before and am very familiar with it."
Bob pretty much tore me a new one in front of the boss and said that I had no clue what I was talking about as this was my 2nd day on the job and that I should go back to surfing the net or whatever it was he said along those lines.
Turned out I was 100% spot on and Bob was fired for his unprofessionalism .
|
|
|
|
|
I was surfing code to get a feel for what was being done. I was pleased with the naming conventions because I could tell what was going on just by reading the variable names. Then I read a bug because the code told me exactly what it was doing. Went to my manager, expecting to get my hand slapped for daring to read what was none of my business. Instead I was told it was built per specs. So I asked to see the specs. To my surprise I was given the specs.
These were the most exacting specs I'd ever seen. I agreed that the code exactly matched the specs. The manager looked like she thought the subject was closed. Then I said, it's just too bad the specs are asking to have the code do something incorrectly. We ended up in the lab where I said this code should blow up with threading problems at times. The lab tech pipes up, and says they are having problems with code blowing up with threading problems. THEN the manager was willing to look at the math that immediately told me there was a problem.
I finally was able to prove that if the maximum thread count was 100 and the step count was 20, the current count was 100, it would ask for 20 more threads, when it was 120, it would ask for 20 more. It would only stop asked for more threads when you reached 121. I can't remember which but setting a + to - or vs versa would have solved the problem or switching the side that added or subtracted the step count would be another way to fix it.
|
|
|
|
|
Did you also point out to your boss that it doesn't make any sense to have more threads then CPU cores? (or CPU cores x 2 if you turn on hyperthreading). Give or take... If you are banging 100 threads on a 4 core + hyperthreading (8 threads), you'll lose any performance gains from all the context switching .
|
|
|
|
|
For CPU bound threads this is the case, but if threads are waiting on IO or get to sleep, this is not the case. More threads than cores can sometimes even be a winner for CPU intensive programs if physical memory is the bottle neck under some circumstances (swapping memory to disk is IO that might need to make a thread take a nap). It's nice when you can design for nearly 1-to-1 thread/core relationships, but it's often quicker (in terms of developer time) to mostly write all threads in a style similar to stand alone programs rather than to separate everything into queueable tasklets that don't sleep (they never sleep! but they do run to completion and often schedule a continuation tasklet to handle results of an IO operation or to start up after a given passage of time).
|
|
|
|
|
SledgeHammer01 wrote: 6) don't inline SQL code, use stored procs If you can inline SQL code, your DBA is an idiot for permitting you to do so. Of course that's the case in 85% (WAG) of the SQL environments out there.
The only profiler I use is SQL's and yes, I use it to find slow performance code, but that's because I didn't write most of the code, so I don't know it.
I haven't the faintest how to use a profiler to improve performance. To me all it's good for is to find code that could stand improvement.
|
|
|
|
|
A profiler is a tool like anything else. It can sometimes expose inefficiencies that you never would have thought of, or other times be useless (e.g. you can't fix what is using most of the CPU time/memory without a significant redesign). A person's assumptions of what is and isn't efficient can also be flawed.. Even with an experienced developer, when it is based on past observations, which could dramatically change with a single new release of your runtime/external libraries/compiler.
The same could be said about using a debugger vs. just adding debug logging. With a debugger you may be wasting a lot of time tediously stepping through the code execution, instead of letting it run and simply browsing the debug log to narrow down the problem. But sometimes simple debug output isn't enough, and a debugger is required.
|
|
|
|
|
As of last night, for some reason, I could not view some PNG files on a website that I manage. Weird as hell! Changing them to JPGs and they were fine. Anyone had something similar recently?
|
|
|
|
|
Maybe you're hiding the PNG files in the web.config or the images with such extension are denied access to in your settings. Possible errors are like this.
Favourite line: Throw me to them wolves and close the gate up. I am afraid of what will happen to them wolves - Eminem
~! Firewall !~
|
|
|
|
|
Possibly. Will have to check the GoDaddy settings. I know I haven't touched it and there's no on else working on this.
|
|
|
|
|
Bassam Abdul-Baki wrote: GoDaddy
I think I have isolated your issue.
What do you get when you cross a joke with a rhetorical question?
---
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
|
|
|
|
|
It might be mime type mapping. It used to be browsers would ignore that for images, but now they will error out.
|
|
|
|
|
Not this or that problem after all. For some reason, having spaces in long filenames (%20) appears to be a problem. Short names are fine. Underscores are fine. Renamed all files to use underscores instead of spaces. Inherited poblem.
|
|
|
|
|
Just curious, did you try using + 's instead of %20 's in the URLs? While they *should* be decoded to the same thing, maybe the server was treating them different.
|
|
|
|
|
No. I haven't had time to test it to see if it's just that website even. Thanks!
|
|
|
|
|
I was reading about the improvements in C# 6, and I can't wait to try this one out, even though the syntax is ugly as sin.
Quote: Null Propagation Operator
The null propagation operator is a concise syntax that enables chaining ‘.’ operations without checking each receiver against null. We can write expressions such as:
var zip = customers?.FirstOrDefault()?.Orders?.FirstOrDefault()?.Address?.Zip;
The value of zip is either the zip code of the first order from the first customer, or null if any of the expresssions return null (customers, FirstOrDefault(), Orders, FirstOrDefault(), or Address). If the Zip property of Address is a value type, zip is the the corresponding nullable value type.
This can simplify that “arrow” style of coding where we have multiple nested if statements where each if clause checks a variable against null.
from: http://thebillwagner.com/blog/overview-of-c-6-language-enhancements[^]
|
|
|
|
|
Agreed, this is a really nice syntax extension (yes its ugly), and may even help reduce the number of null references exceptions.
More stuff like this, and less of the async/await type stuff please.
Regards,
Rob Philpott.
|
|
|
|
|
I like both. I've worked on many projects that used IAsyncResult and the async/await syntax would have really really helped me out.
|
|
|
|
|
..yes, you're right, but, I'm going to miss the NullReferenceException. I liked that annoying little fella!
But I am obviously going to try this out. It is a short form of the try catch block for the NullReferenceException.
Favourite line: Throw me to them wolves and close the gate up. I am afraid of what will happen to them wolves - Eminem
~! Firewall !~
|
|
|
|
|
Nice, indeed.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
|
It can be useful, but also very bad. Think about such code in your sample, with NullReferenceException you had a way to know where the chain broken...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Not without putting it on separate lines. I've found myself doing hacks with either the ternary operator, or
var a = (obj ?? new Obj()).Value
or other ugly hacks just to make things a little more succinct than nesting a bunch of if statements to get the same effect.
|
|
|
|
|
When you had the punishment of NullReferenceException hang over your neck you would not dare to write all that in a single line anyway, but checking each and every part for existence an validity...IMHO it's a much better way - 'fail with grace' I think...
The new syntax is ugly and can get you into serious problems when need to be debugging...
The only sure thing - it will increase Q&A income
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I can see that you don't like this at all, and it doesn't fit the style of code that you write. I'm sharing something that works for me.
However, there is plenty of code I write where this is exactly the behavior I need. There are many forms that I deal with where null signifies something that isn't filled out, and I currently have to write extra code that is harder to read.
|
|
|
|