简体   繁体   English

原生Android VS Flex移动文件系统速度

[英]Native Android VS Flex mobile filesystem speed

So i am building a couple of benchmark apps for android in order to evaluate different technologies ( Flex , Native , Html5 ,etc) and determine which is best according to my method. 因此,我正在为Android构建一些基准测试应用程序,以便评估不同的技术( FlexNativeHtml5等),并根据我的方法确定哪种技术最好。

The problem that i came across is that while the Native app was unmatched on simple arithmetic tests it's not the same when reading or writing files. 我遇到的问题是,尽管本机应用程序在简单的算术测试中无与伦比,但在读取或写入文件时却不尽相同。

More specific the Native application scored 92ms on counting from 1 to 10m while Flex needed an avg of 13sec for the same action. 更具体地说, Native应用程序从1到10m的计数为92毫秒,而Flex的相同动作平均需要13秒。

In Reading 10000 lines of text the Native app took 800ms when Flex needed 450 and in writing the native app took 3560ms when flex took only 860ms. 在读10000行文本的Native应用程序在800ms了当Flex需要450,并以书面的原生应用了3560ms时,Flex只有860ms了。

The only difference on the first test was that the native app used a bufferstream when in flex i used a Filestream . 第一次测试的唯一区别是,当我在flex使用Filestream时,本机应用程序使用了缓冲流。 Can this cause this inconsistency? 这会导致这种不一致吗? Any ideas where to go from here? 有什么想法从这里去吗?

I am using java for my native. 我使用Java作为本机。 so here is my source: 所以这是我的来源:

Flex: 柔性:

            loadingLbl.visible=true;
            var startTime:int = getTimer();     
            te1.text=""+startTime;
            var file:File = File.desktopDirectory.resolvePath("samples/test.txt");
            var pathFile:String = file.nativePath;
            var stream:FileStream = new FileStream()
            stream.open(file, FileMode.WRITE);

            for(i=0; i<=100000; i++)
            {
                //list.dataProvider.addItem(""+i);
                stream.writeUTFBytes("word"+i+"\n");                    
            }

            stream.close();
            results.text=""+file.nativePath;
            var currentTime:int = getTimer();
            var timeRunning:int = (currentTime - startTime);


            te0.text=""+currentTime;
            timerLabel.text= "Total time: "+timeRunning+" ms";
            loadingLbl.visible=false;

Android Version: Android版本:

{ {

    String temp="";
    TextView time = (TextView)findViewById(R.id.timerLbl);
    long start=System.nanoTime();

    File sdcard = Environment.getExternalStorageDirectory();

    //Get the text file
    File myfile = new File(sdcard,"myFile.txt");

    try {

        BufferedWriter writer = new BufferedWriter(new FileWriter(myfile));

        for(int i=0;i<100000;i++)
        {
            temp="word"+i;
            writer.write(temp);
            writer.newLine();
        }

        writer.flush();
        writer.close();
    } catch (FileNotFoundException e) {
        // handle exception
    } catch (IOException e) {
        // handle exception
    }
    TextView tv = (TextView)findViewById(R.id.result);

    //Set the text
    tv.setText("Last word was: "+temp);
    long end=System.nanoTime();
    time.setText("Took: " + ((end - start) / 1000000+"ms"));

}

Can the difference of using bufferwriter be the source of getting different results? 使用bufferwriter的不同之处能否成为获得不同结果的源头?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM