Reputation
10,168
Top tag
Next privilege 15,000 Rep.
Protect questions
Badges
1 23 43
Newest
 Yearling
Impact
~578k people reached

Jan
29
comment How to mentor *senior* developer?
1) You might want to take a Dale Carnegie course. It will give you pointers on how to be a leader, which is what you're trying to do. 2) Learn from him. You may be strong with "the Force", but the Force isn't always right.
Jan
16
comment How can I test for performance issues in a specific piece of code?
@Zibbobz: What to do: Run it under a debugger, and in the execution phase where it is sluggish, manually interrupt it and examine the call stack. If you do this a few times, it will show you what the problem is. Problems with that duplicate question: Knowing which routines have the highest execution count does not reveal the problem. See point 6 here. Don't assume it's a matter of narrowing down to class and function. Look instead for what it's doing and why.
Jan
16
comment MVC controller and decoupling explained
@Narek: That's the model-view-controller idea, where you can change the view without having to change the model. There can be many different views of the model, or none, so you don't want the model to depend in any way on the ways in which is viewed. To me, that makes a certain sense, except in a situation where the model structure can change frequently. In that case, it is important to minimize the effort to upgrade the corresponding view structure.
Jan
15
comment MVC controller and decoupling explained
@Narek: The idea that M should not "know about" V is so that different Vs can be made more easily. In my experience, changes to M are more likely , and if V is more closely bound to M, the corresponding changes can be done more easily. Ideally, one should not have to have a separate C at all, because all the information needed to specify it is already included in M and V. Sorry it's more than 2 words, but we're talking about an order of magnitude savings in developer effort, which turns into a more responsive dev. cycle.
Jan
14
comment MVC controller and decoupling explained
I know I'm in a contrarian minority, but I have a problem with the idea that decoupling the M, V, and C are a good idea. (I suppose in some/many situations there is no good alternative.) My alternative is here, here, and here, and there is plenty of public code if you're interested.
Nov
23
comment Optimization: How much time saved is considered worth it?
First, does it bother anyone, like a user or you? If not, you don't have a problem, so don't fix it. Second, don't look at absolutes, like minutes or seconds. Look at fractions, like 1%, 10%, or 90%. Saving a minute is worthless if it is spread out over a day, because it is less than 0.1%, and there are certain to be bigger savings elsewhere.
Nov
12
comment In general, is it worth using virtual functions to avoid branching?
@gnasher729: Well, the first thing I do is get stack samples, and on each one, examine what the program is doing and why. Then if it spends all its time in leaves of the call tree, and all the calls are truly unavoidable, does it matter what the compiler and hardware do. You only know method dispatch matters if samples land in the process of doing method dispatch.
Nov
12
comment In general, is it worth using virtual functions to avoid branching?
@gbjbaanb: Everybody says they've got "highly critical sections". How do they know? I don't know something is critical until I take, say, 10 samples, and see it on 2 or more of them. In a case like this, if the methods being called take more than 10 instructions, the virtual function overhead is probably insignificant.
Nov
6
comment In general, is it worth using virtual functions to avoid branching?
The problem with this question is it presupposes that this is big enough to worry about. In real software, performance problems come in big chunks, like slices of pizza of multiple sizes. For example look here. Don't assume you know what the biggest problem is - let the program tell you. Fix that, and then let it tell you what the next one is. Do this half a dozen times, and you might be down to where virtual function calls are worth worrying about. They never have, in my experience.
Nov
4
comment How can I diagnose async/await deadlocks?
Are the deadlocking threads/processes on the same hardware, so you can get simultaneous stack traces as @svick suggested? If A is waiting for something from B, and B is waiting for something from A, this should be clear from examining both of their stacks.
Oct
30
comment Fundamental issues of programming
@DocBrown is right. The supposed tradeoff between performance and maintainability is merely anecdotal. But there's a bigger issue: don't look at performance by taking a magnifying glass to the code. Instead, get it running and then let it tell you what takes time. The bigger the code is, the more likely there are multiple ways to speed it up. Want a surprise? Take a look at this case where the speedup factor is almost 3 orders of magnitude. That's like 20 minutes to 1 second.
Oct
16
comment How can I be quicker at resolving application performance problems
You don't say how you go about choosing what to optimize. You're not alone - most programmers don't know how, and don't know they don't know. They are liable to think it has to do with cache-misses or big-O. Also, they are frustrated that the Agile methods don't seem to allow them to do performance tuning. I do a lot of performance tuning, but it can a frustrating experience just because most programmers don't understand it.
Oct
8
comment Do nested conditionals have a significant performance impact?
Nesting doesn't cost anything. What hurts performance is doing things you don't need to.
Sep
29
comment Performance concern in object oriented languages
Performance problems are never where you think they are. I only know of one absolutely sure-fire can't-miss way to find them, and that is to use a small number of random stack samples. I work in a large C# project, and it has found some large speedups. The point is, assuming there is a real performance problem, no matter what it is, fixing it will save some fraction of time, like from 10% to 90%. The probability you will catch it in the very act on any single sample is at least that large. (It is extremely unlikely to be what you're guessing.)
Sep
9
comment What is O(m+n) and O(m*n) in Big O notation?
@MetaFight: yippee
Sep
8
comment What is O(m+n) and O(m*n) in Big O notation?
@MetaFight: now it does.
Jun
23
comment What is the best aproach for coding in a slow compilation environment
@John: Yeah, a well-written compiler should (IMHO) be I/O bound.
Jun
22
comment How to find bottlenecks in an application?
@ChocoDeveloper: Revisiting this 2 years later. It's like interviewing 10 candidates for a job, versus 1000. With the small number you're going to pay close attention to each one. With the large number you're going to skim, missing important details. That's the trouble with most profilers - it's not the taking of samples, it's the conversion to numbers.
May
8
comment How does modulus work?
To answer your question, there is an integer division instruction, which produces both a quotient and a remainder, and the modulus is just the remainder. But pay attention to @uesp comment. The division takes around 1e-9 seconds, even if the compiler hasn't precalculated it (which in this case it has). The cout << takes around 1e-3 seconds, so this is like trying to weigh a hair by weighing the Bison who owns it.
Apr
28
comment List comparing techniques for faster performance
+1 @cap7: This is what I would do - sort both lists and use a merge loop. You're not clearing the lists, just indexing through them.