Does one method call takes one CPU cycle?

350 Views Asked by At

Suppose we have following method

private int add(int num_1, int num_2) 
{
  return num_1+num+2;
}

Does calling this method consumes one cpu cycle ? As there are 1 billion cycles in 1 ghz.

1

There are 1 best solutions below

0
On

No. consider the function call sleep(5000) which causes your code to pause for 5 seconds. That would take more than 1 clock cycle.