Is it possible to somehow find out how many lines are in a function? It is possible to recursively calculate all the lines for all subfunctions to be called. This behavior should be:

if (lines(&foo) > 100500) { // запускаем в отдельном потоке или процессе } else { // просто вызываем } 
  • In general, it is impossible to say how much in a given function call the performance of the processor, memory, disk space and other computing resources will be required. This, by the way, greatly complicates the construction of planners even in homogeneous and especially in herterogenic computing environments. - pepsicoca1

1 answer 1

Sorry, I’m not getting into a comment ...

How many lines, for example, in the factorial function:

 int factorial(int n) { // Аккумулятор int r = 1; // Цикл по всем цислам 1..n for(int i = 1; i <= n; ++i) { // Вычисляем произведение r = r * i; } return r; } 

Twelve? Or one?

 int factorial(int n) { int r = 1; for(int i = 1; i <= n; r*=i++); return r; } 

And how do you evaluate the lines of the called system functions?

And what is the criterion - the number of rows. As if fast sorting in 200 lines will work longer than sorting in a choice of 20 lines for, say, a million array.

Convinced ... um ... insolvency of your idea?

  • Well, I doubt that adequate lines will push 200 lines into 1 ... And how do you suggest then evaluate the speed without starting the function? - credit
  • one
    In absentia - absolutely nothing. In the best case, the estimation of the complexity of the algorithm ... And so - by measurements, measurements, measurements. By the way, you do not take into account at all, for which input data we work - and this is extremely important. - Harry