I am using c++ and want to create a method, that terminates after a given timespan (e.g. 50microseconds) like a contract algorithm.
The method is using loops so my idea was to use the std::chrono::high_resolution_clock::now()
method to measure elapsed time.
Unfortunately this is not very fast and the method runs way slower than the initial one.
What is the best / a better way to archieve the same result?
How do other contract / anytime algorithms handle this problem?