On Oct 10, 2005, at 2:25 PM, Frans Englich wrote:
What makes me ask these questions, is that I have code which (according to my opinion) severely needs virtual inheritance(VI). The code VI would affect is not under my veto power, and the maintainers of that code have so far given as comment "VI is out of the question. Period," without giving a deeper
motivation, except "performance."

Benchmark on a machine with a timestamp counter (rdtsc on x86 as I recall). Do up two versions of the code, one the right way, and the other cleverly avoiding VI. Time them, collects all relevant numbers, then see what the numbers are, then argue from that position. Actual numbers are sometimes more compelling. The timings can be for very small things, not whole program execution times. Like, time to do:

    ref->add_refernce (this);

or whatever you're changing. If it says you've added 3 clocks cycles to a base of 100 clock cycles, and gcov data says that in whole program, it runs 987234 times, then you can say your code slows it down by roughly 3*987234 clock cycles, or 329 usecs (for a 3 GHz processor), you can then express this as a % of the total run time.

Another way, is to find a way to speed up the code in some other aspect, to pay for the new cost you are introducing, then bargain with then, say, if you let me slow this down, I will pay for it by having a net increase in speed of x. It is then harder for them to say no. It shows that you are serious above performance and willing to do what it takes to make things nice.

Hopefully they understand the term premature optimization.

Reply via email to