interpret-only模式改为speed模式的测试时间对比

来源:互联网 发布:电梯维修需要编程吗 编辑:程序博客网 时间:2024/06/04 01:03
一.interpret-only模式改为speed模式的测试时间对比


修改 /system/build.prop 文件中的 dalvik.vm.dex2oat-filter=interpret-only 为  dalvik.vm.dex2oat-filter=speed , 写一个测试时间的应用程序 TestTime.apk , 对比修改前后TestTime.apk 的执行时间。
//TestTime.java 测试时间主要代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView message = new TextView(this);
long start = System.currentTimeMillis(); //获取系统当前时间(ms)
for(long i = 0; i < 1000000000; i++);
message.setText("hello world,took" + (System.currentTimeMillis() - start) / 1000f + "seconds");
setContentView(message);
}


测试结果如下:


for循环的大小为300000000:
interpret-only : 50.655 s , 52.372 s , 51.311 s , 51.200 s , 51.724 s , 平均值:51.4524 s
speed : 50.943 s , 50.857 s ,  51.031 s , 50.675 s  , 50.745 s  , 平均值:50.906 s


for循环的大小为1000000000:
interpret-only: 168.863 s , 168.286 s , 168.859  s , 168.347 s ,168.211 s , 168.623 s , 平均值:168.5315 s
speed: 167.771 s , 167.576 s ,  168.103 s ,  167.503 s ,  167.932 s ,  167.809  s , 平均值:167.7823 s


for循环的大小为5000000000:
interpret-only: 847.449  s , 849.570 s , 848.124  s , 847.262 s , 848.031 s ,平均值:848.0872 s
speed: 847.197 s ,  848.158 s , 848.154 s , 847.279s , 847.418 s , 平均值:847.6412 s 


从以上数据可以看出,由 interpret-only 模式改为 speed 模式后,速度略有提升。
0 0
原创粉丝点击