How do you know the execution time of the function?

Asked 2 years ago, Updated 2 years ago, 20 views

I want to know the execution time of the function, is there only a way to use the Timer utility class?

When I searched on Google, most of them used timer. This is a thread, but I don't really like it

java timing

2022-09-22 13:19

1 Answers

long startTime = System.nanoTime();
methodToTime();
long endTime = System.nanoTime();

long duration = (endTime - startTime);

The old way isn't bad.


2022-09-22 13:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.