Answer the question
In order to leave comments, you need to log in
How to return the time of standard collection methods in java?
Whether prompt there is a method returning time operation of standard methods in a collection?
Answer the question
In order to leave comments, you need to log in
long startTime = System.nanoTime();
someList.contains(someVar);
long endTime = System.nanoTime();
long duration = endTime - startTime;
if the abbreviation AOP does not scare you, you can try. there are plenty of examples on the internet.
for example
, but under the hood it will be exactly the same as suggested by Sergey Gornostaev
Why do you need to profile the standard methods of standard collections in java ? Have you run into them? I highly doubt it, in 99% of cases the network / database trip / reading and writing to disk slows down. If you need to "speed up" the standard Java library, you have chosen the wrong tool. Rewrite bottlenecks in C.
Here is a very useful squat to profile "your" methods. It is better to use some complete solution for this, for example based on this metrics.dropwizard.io/3.1.0/getting-started
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question