我已經確定了調用Java的File.listFiles()
在從Win 7的客戶端文件夾SAMBA是極其緩慢,比從Mac客戶端較慢實際上幾乎100倍上市。 (這兩個客戶端都運行Java 7)。兩個客戶端自然在同一個1GB局域網上。客戶已經從他的Win XP客戶端進行測試,並且獲得了比他的Win7客戶端更好的性能。有誰知道如何解決這個問題?極其緩慢的文件使用Java + SAMBA + Win 7的
一些測試數據,其中包括定時: 清單超過SAMBA 31頁的文件夾( 「QNAP」 NAS磁盤):在Mac
listing \\nas\Public\David\Remote Stocks: 0.0s listing \\nas\Public\David\Remote Stocks\Animals: 0.093s listing \\nas\Public\David\Remote Stocks\Animals\.jalbum: 0.312s listing \\nas\Public\David\Remote Stocks\Animals\.jalbum\thumbs: 0.405s listing \\nas\Public\David\Remote Stocks\album: 1.248s listing \\nas\Public\David\Remote Stocks\album\Animals: 1.31s listing \\nas\Public\David\Remote Stocks\album\Animals\thumbs: 1.388s listing \\nas\Public\David\Remote Stocks\album\Animals\slides: 1.762s listing \\nas\Public\David\Remote Stocks\album\Animals\res: 2.542s listing \\nas\Public\David\Remote Stocks\album\Sports: 2.761s listing \\nas\Public\David\Remote Stocks\album\Sports\thumbs: 2.839s listing \\nas\Public\David\Remote Stocks\album\Sports\slides: 3.229s listing \\nas\Public\David\Remote Stocks\album\Sports\res: 3.978s listing \\nas\Public\David\Remote Stocks\album\res: 4.196s listing \\nas\Public\David\Remote Stocks\album\Scenic: 4.695s listing \\nas\Public\David\Remote Stocks\album\Scenic\thumbs: 4.773s listing \\nas\Public\David\Remote Stocks\album\Scenic\slides: 5.194s listing \\nas\Public\David\Remote Stocks\album\Scenic\res: 5.99s listing \\nas\Public\David\Remote Stocks\album\People: 6.208s listing \\nas\Public\David\Remote Stocks\album\People\thumbs: 6.302s listing \\nas\Public\David\Remote Stocks\album\People\slides: 6.692s listing \\nas\Public\David\Remote Stocks\album\People\res: 7.472s listing \\nas\Public\David\Remote Stocks\.jalbum: 7.659s listing \\nas\Public\David\Remote Stocks\Sports: 7.768s listing \\nas\Public\David\Remote Stocks\Sports\.jalbum: 7.909s listing \\nas\Public\David\Remote Stocks\Sports\.jalbum\thumbs: 7.987s listing \\nas\Public\David\Remote Stocks\Scenic: 8.486s listing \\nas\Public\David\Remote Stocks\Scenic\.jalbum: 8.642s listing \\nas\Public\David\Remote Stocks\Scenic\.jalbum\thumbs: 8.72s listing \\nas\Public\David\Remote Stocks\People: 9.282s listing \\nas\Public\David\Remote Stocks\People\.jalbum: 9.422s
同一列表:
運7
listing /Volumes/Public/David/Remote Stocks: 0.0s listing /Volumes/Public/David/Remote Stocks/Animals: 0.013s listing /Volumes/Public/David/Remote Stocks/Animals/.jalbum: 0.018s listing /Volumes/Public/David/Remote Stocks/Animals/.jalbum/thumbs: 0.022s listing /Volumes/Public/David/Remote Stocks/album: 0.027s listing /Volumes/Public/David/Remote Stocks/album/Animals: 0.03s listing /Volumes/Public/David/Remote Stocks/album/Animals/thumbs: 0.032s listing /Volumes/Public/David/Remote Stocks/album/Animals/slides: 0.034s listing /Volumes/Public/David/Remote Stocks/album/Animals/res: 0.038s listing /Volumes/Public/David/Remote Stocks/album/Sports: 0.04s listing /Volumes/Public/David/Remote Stocks/album/Sports/thumbs: 0.042s listing /Volumes/Public/David/Remote Stocks/album/Sports/slides: 0.046s listing /Volumes/Public/David/Remote Stocks/album/Sports/res: 0.05s listing /Volumes/Public/David/Remote Stocks/album/res: 0.052s listing /Volumes/Public/David/Remote Stocks/album/Scenic: 0.058s listing /Volumes/Public/David/Remote Stocks/album/Scenic/thumbs: 0.064s listing /Volumes/Public/David/Remote Stocks/album/Scenic/slides: 0.068s listing /Volumes/Public/David/Remote Stocks/album/Scenic/res: 0.074s listing /Volumes/Public/David/Remote Stocks/album/People: 0.08s listing /Volumes/Public/David/Remote Stocks/album/People/thumbs: 0.082s listing /Volumes/Public/David/Remote Stocks/album/People/slides: 0.085s listing /Volumes/Public/David/Remote Stocks/album/People/res: 0.089s listing /Volumes/Public/David/Remote Stocks/.jalbum: 0.091s listing /Volumes/Public/David/Remote Stocks/Sports: 0.103s listing /Volumes/Public/David/Remote Stocks/Sports/.jalbum: 0.106s listing /Volumes/Public/David/Remote Stocks/Sports/.jalbum/thumbs: 0.108s listing /Volumes/Public/David/Remote Stocks/Scenic: 0.11s listing /Volumes/Public/David/Remote Stocks/Scenic/.jalbum: 0.122s listing /Volumes/Public/David/Remote Stocks/Scenic/.jalbum/thumbs: 0.124s listing /Volumes/Public/David/Remote Stocks/People: 0.126s listing /Volumes/Public/David/Remote Stocks/People/.jalbum: 0.133s
我終於嘗試在Windows上執行多線程列表來克服網絡延遲效應。它有所幫助 - 從9到3秒,即3倍的速度,但仍然顯着低於我的MacBook Pro客戶端測量的0.133s的性能。
你有一個代碼片段?調用'File.listFiles()'只會返回一個數組,所以在循環數組並打印名稱之後?還有什麼?編輯:除非這些日誌來自你的NAS ...? – BruteForce 2013-02-19 17:51:27
你可以試試['Files.newDirectoryStream'](http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newDirectoryStream(java.nio.file.Path) )。它的主要優點是可以遞增列出文件,而無需首先列出整個目錄,但它可能表現更好。 – 2013-02-21 12:38:05