c++ - Will std::cout affect timers? -


i have graphics program, , want measure time function calls take. since not sure how std::cout works under hood, wanted ask if calls in between timer calls affect performance. know it's slow in naturally not put in functions i'm measuring, buffered/asynchronous effect linger after call returns in way? looking (pseudocode):

timer->start(); runsomefunction(); timer->stop(); std::cout << timer << std::endl; // affect next timer event? timer->start(); runanotherfunction(); timer->stop(); std::cout << timer << std::endl; // etc 

in short, no.

longer answer: however, depend, cout going to, , system running on.

typically, internals of cout use sort of "write file" system call, file "standard out" filehandle - may sort of display device, window or file if output redirected. may of course lead sort of interrupt or process elsewhere running (e.g. "cmd.exe" in windows or "xterm" or similar in linux/unix). if functions short, sort of "interference" may sufficient alter results - of course, it's equally possible web-browser waking check if facebook has new items, or email software, or network other system has similar effect. however, in modern system decent multi-core processor (as long system isn't running 100% cpu usage), these effects should small , not account - whether talking cout or of other potential factors.

edit: additionally, sensitive code, effect of calling cout (or other function more couple of lines long [or loops around reading large lumps of memory, if few lines]) affect cache-content, may affect execution of code.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -