java三种实例对象方式性能比拼

测试单位:毫微秒

测试次数:5

第一种:普通的new对象

第二种:用获取到的Class对象调用newInstance()方法

第三种:用获取到类中的Constructor对象调用newInstance()方法

new
cost time:15029843
cost time:9462656
cost time:9229386
cost time:9313753
cost time:9725817

 

Class.newInstance
cost time:1114809564
cost time:1083132353
cost time:1078971210
cost time:1097584191
cost time:1088212608

 

Constructor.newInstance
cost time:1021233983
cost time:995615364
cost time:992249853
cost time:1005193956
cost time:1015676294

你可能感兴趣的:(java,测试,Class,Constructor)