How to Measuring performance in Java -
this question has answer here:
how 1 measure performance of method/period of time in application in java? there class made functionality?
there 2 ways:
testing @ design time. means, perform tests when designing application. may tempted create methods , naively measure them using
system.nanotime()
(or, in worst case,system.currenttimemillis()
), , naive approach because you're missing lot of concepts handling micro benchmark. still, if want manually benchmark methods, @ least follow proper rules micro benchmark. imo should not reinvent wheel, instead use benchmark framework junitbenchmarks or caliper can measure time of algorithms/methods using unit testing.testing @ run time. means, measure performance when application running, in dedicated environment similar production environment. scenario, use profiler. there lot of profilers java applications, free license visualvm , java mission control (this comes jdk 7 u40) shipped in jdk distribution commercial products yourkit.
Comments
Post a Comment