0

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.

私が遭遇した問題は、ネイティブアプリは単純な算術テストでは比類のないものでしたが、ファイルの読み取りまたは書き込みでは同じではないということです。

より具体的に言えば、Nativeアプリケーションは 1 から 10 分のカウントで 92 ミリ秒のスコアを記録しましたFlexが、同じアクションには平均 13 秒が必要でした。

10000 行のテキストを読み取る場合、NativeアプリはFlex450 が必要なときに 800 ミリ秒かかり、ネイティブ アプリを書き込む場合は、フレックスが 860 ミリ秒しかかからないときに 3560 ミリ秒かかりました。

最初のテストでの唯一の違いは、ネイティブ アプリflexFilestream. これにより、この不一致が発生する可能性がありますか? ここからどこへ行くべきか?

4

1 に答える 1

0

I am using java for my native. 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:

{

    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?

于 2013-02-27T16:57:08.663 に答える