import java.lang.reflect.Method; public class GetMethodsBench { public static void main(String[] args) { int count = 1000000; if(args.length >= 1) { int tmp = Integer.valueOf(args[0]); if(tmp > 0) count = tmp; } Class cls = String.class; long begTime = System.currentTimeMillis(); for(int i = 0; i < count; i++) cls.getMethods(); long endTime = System.currentTimeMillis(); System.out.printf("Elapsed time = %s ms\n", endTime - begTime); } }