1

Sometimes, when I decide to process the function, I fear that it takes an infinite amount of time to finish the process, making my working environment occupied for a while (and to make it worse, in some cases disrupting the process by esc doesn't work or work only so much later).

So I want to know in advance whether a given function will be finished in an endurable time, and approximately how much it is expected to take to finish the function. This is not a question about how to measure the time it took to complete the function.

So is it possible to know it approximately in advance?

Community
  • 1
  • 1
Blaszard
  • 30,954
  • 51
  • 153
  • 233
  • 1
    Gregor is right that the in the most general case, this in unknowable. But obviously, people writing code _do_ estimate running time prior to committing to a full run. You just have to write your code in a fashion that it is runnable in increments. Test on a small subset of your data; test on only 10-20 iterations instead of 50k and do some rough extrapolation. – joran Nov 12 '16 at 05:20

1 Answers1

2

No. This is not possible in R or any other language. Whether or not the program will ever stop is called the "halting problem", and it is provably unsolvable.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294