Re: +3.0 microsecond for iterating empty vectors
Ayon kay Greg:
krbyxtrm wrote:
hello people,
i have implemented my code this way
start = read_timer(); // for profiling
if ( !any_vec.empty() )
{
std::for_each(
any_vec.begin(),
any_vec.end(),
retrieve); // where retrieve is an empty function for now...
}
end = read_timer();
duration = end - start ; // minus counter error
with this code and having empty callback function,
it duration = 1.2e-1 us
maybe i will have to see some std::vector implemtation manual to check
whether i'm using a debug-enable version, as of now i have from
http://www.sgi.com/tech/stl/Vector.html
but it does not have what Ivan Vecerina is telling.
How much time do you think these lines of code should reasonably take?
In other words, by what measure is the one-ten millionth of a second
being spent here too time-consuming?
From my own experience, optimizing any operation not measured in
milliseconds is probably not worthwhile. So unless the program intends
to execute this code 10,000 times in a row - and do so repeatedly -
then this kind of "bottom-up" optimization is unlikely to be
productive. What is needed is a "top-down" approach, in which the
entire program's execution is timed. It is necessary to account for all
of the time that a program spends executing, in order to know where
optimizations are likely to improve performance.
Greg
Greg,
Entire application's performace for my application is not quite
applicable, i should say,
application's initialization, etc for me is good enough, but the real
bottleneck is that code i'd been posting, since its not just a simple
vector/stack to iterate, it would store thousands of data, vector data
would be added, subtracted, etc. It holds not only plain data, it holds
function pointers, buffers and another pointer and another buffer, i
just made it simple to illustrate this problem.
-k-