Hi,
I am running a simulation and want to print out the execution time at each iteration. Is there a C++ command for this?
Shuo
Hi,
I am running a simulation and want to print out the execution time at each iteration. Is there a C++ command for this?
Shuo
Not to be pedantic, but C++ does not have "commands" per se.
Anyway, built into C++, no, unless you count the clock() function or even the time_t functions. The latter is probably your best bet, but it depends upon how precise and accurate you need to be.
If you're looking for anything which is consistently below 1 second, then you need to be specific about which OS/Compiler you're using.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
clock() is as close as you can usually get for a portable, "high precision" timer. It is not very precise, but it will give you a decent timing. It usually manages to be precise to about 0.1 second, but shorter times than that requires less portable solutions, usually.
http://www.hmug.org/man/3/clock.php
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.