how do i make a segment of program stop after a while, say 30 seconds and give a variable whatever it gets so far?
thanks in advance.
how do i make a segment of program stop after a while, say 30 seconds and give a variable whatever it gets so far?
thanks in advance.
The only general solution (and fortunately the easiest if you have access to source code) is to modify the "segment" so it periodically checks elapsed time and, when required, print out the required variables.
For example, if the segment is executing a loop, add code to the loop body that checks time and prints variables of interest.
_Mike writes: c++ time
Google replies: time - C++ Reference
If you want higher resolution on your timers I think you'd have to use some platform-specific APIs or a 3rd-party library.
To be quite frank, you simply use a loop of some kind, e.g. a while loop. Pseudocode:
while now - start_time < 30
Do_Stuff
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"