I'm creating a program where everytime it goes to a function it gets the execution time of that function, but the problem is that when once it enters the first function the next functions will get 0 or 1 ms of execution time:
function1:
long start = System.currentTimeMillis();
//
//
//some code
//
//
//
long end = System.currentTimeMillis();
System.out.println("function1 took: " + (end - start) + "ms");
function2:
long start = System.currentTimeMillis();
//
//
//some code
//
//
//
long end = System.currentTimeMillis();
System.out.println("function2 took: " + (end - start) + "ms");
function3:
long start = System.currentTimeMillis();
//
//
//some code
//
//
//
long end = System.currentTimeMillis();
System.out.println("function3 took: " + (end - start) + "ms");
the output is:
function1 took: 49ms
function2 took: 1ms
function3 took: 0ms
As you can see, after the first funtion, it seems that the time is not calcualted correctly for the following functions. hope you can answer my doubt.