gpt4 book ai didi

java - 使用 Java + SAMBA + Win 7 列出文件非常慢

转载 作者:行者123 更新时间:2023-12-02 07:15:39 25 4
gpt4 key购买 nike

我发现从 Win 7 客户端通过 SAMBA 文件夹调用 Java 的 File.listFiles() 非常慢,实际上比从 Mac 慢了近 100 倍客户。 (两个客户端都运行 Java 7)。两个客户端自然位于同一个 1GB LAN 上。一位客户在他的 Win XP 客户端上进行了测试,获得了比他的 Win7 客户端好得多的性能。有谁知道如何解决这个问题吗?

一些测试数据,包括时间:通过 SAMBA(“QNAP”NAS 磁盘)列出 31 个文件夹:

赢7:

listing \\nas\Public\David\Remote Stocks: 0.0slisting \\nas\Public\David\Remote Stocks\Animals: 0.093slisting \\nas\Public\David\Remote Stocks\Animals\.jalbum: 0.312slisting \\nas\Public\David\Remote Stocks\Animals\.jalbum\thumbs: 0.405slisting \\nas\Public\David\Remote Stocks\album: 1.248slisting \\nas\Public\David\Remote Stocks\album\Animals: 1.31slisting \\nas\Public\David\Remote Stocks\album\Animals\thumbs: 1.388slisting \\nas\Public\David\Remote Stocks\album\Animals\slides: 1.762slisting \\nas\Public\David\Remote Stocks\album\Animals\res: 2.542slisting \\nas\Public\David\Remote Stocks\album\Sports: 2.761slisting \\nas\Public\David\Remote Stocks\album\Sports\thumbs: 2.839slisting \\nas\Public\David\Remote Stocks\album\Sports\slides: 3.229slisting \\nas\Public\David\Remote Stocks\album\Sports\res: 3.978slisting \\nas\Public\David\Remote Stocks\album\res: 4.196slisting \\nas\Public\David\Remote Stocks\album\Scenic: 4.695slisting \\nas\Public\David\Remote Stocks\album\Scenic\thumbs: 4.773slisting \\nas\Public\David\Remote Stocks\album\Scenic\slides: 5.194slisting \\nas\Public\David\Remote Stocks\album\Scenic\res: 5.99slisting \\nas\Public\David\Remote Stocks\album\People: 6.208slisting \\nas\Public\David\Remote Stocks\album\People\thumbs: 6.302slisting \\nas\Public\David\Remote Stocks\album\People\slides: 6.692slisting \\nas\Public\David\Remote Stocks\album\People\res: 7.472slisting \\nas\Public\David\Remote Stocks\.jalbum: 7.659slisting \\nas\Public\David\Remote Stocks\Sports: 7.768slisting \\nas\Public\David\Remote Stocks\Sports\.jalbum: 7.909slisting \\nas\Public\David\Remote Stocks\Sports\.jalbum\thumbs: 7.987slisting \\nas\Public\David\Remote Stocks\Scenic: 8.486slisting \\nas\Public\David\Remote Stocks\Scenic\.jalbum: 8.642slisting \\nas\Public\David\Remote Stocks\Scenic\.jalbum\thumbs: 8.72slisting \\nas\Public\David\Remote Stocks\People: 9.282slisting \\nas\Public\David\Remote Stocks\People\.jalbum: 9.422s

Mac 上的相同列表:

listing /Volumes/Public/David/Remote Stocks: 0.0slisting /Volumes/Public/David/Remote Stocks/Animals: 0.013slisting /Volumes/Public/David/Remote Stocks/Animals/.jalbum: 0.018slisting /Volumes/Public/David/Remote Stocks/Animals/.jalbum/thumbs: 0.022slisting /Volumes/Public/David/Remote Stocks/album: 0.027slisting /Volumes/Public/David/Remote Stocks/album/Animals: 0.03slisting /Volumes/Public/David/Remote Stocks/album/Animals/thumbs: 0.032slisting /Volumes/Public/David/Remote Stocks/album/Animals/slides: 0.034slisting /Volumes/Public/David/Remote Stocks/album/Animals/res: 0.038slisting /Volumes/Public/David/Remote Stocks/album/Sports: 0.04slisting /Volumes/Public/David/Remote Stocks/album/Sports/thumbs: 0.042slisting /Volumes/Public/David/Remote Stocks/album/Sports/slides: 0.046slisting /Volumes/Public/David/Remote Stocks/album/Sports/res: 0.05slisting /Volumes/Public/David/Remote Stocks/album/res: 0.052slisting /Volumes/Public/David/Remote Stocks/album/Scenic: 0.058slisting /Volumes/Public/David/Remote Stocks/album/Scenic/thumbs: 0.064slisting /Volumes/Public/David/Remote Stocks/album/Scenic/slides: 0.068slisting /Volumes/Public/David/Remote Stocks/album/Scenic/res: 0.074slisting /Volumes/Public/David/Remote Stocks/album/People: 0.08slisting /Volumes/Public/David/Remote Stocks/album/People/thumbs: 0.082slisting /Volumes/Public/David/Remote Stocks/album/People/slides: 0.085slisting /Volumes/Public/David/Remote Stocks/album/People/res: 0.089slisting /Volumes/Public/David/Remote Stocks/.jalbum: 0.091slisting /Volumes/Public/David/Remote Stocks/Sports: 0.103slisting /Volumes/Public/David/Remote Stocks/Sports/.jalbum: 0.106slisting /Volumes/Public/David/Remote Stocks/Sports/.jalbum/thumbs: 0.108slisting /Volumes/Public/David/Remote Stocks/Scenic: 0.11slisting /Volumes/Public/David/Remote Stocks/Scenic/.jalbum: 0.122slisting /Volumes/Public/David/Remote Stocks/Scenic/.jalbum/thumbs: 0.124slisting /Volumes/Public/David/Remote Stocks/People: 0.126slisting /Volumes/Public/David/Remote Stocks/People/.jalbum: 0.133s

我最终尝试在 Windows 上执行多线程列表以克服网络延迟影响。它有所帮助,从 9 秒到 3 秒,即快了 3 倍,但性能仍然比我的 MacBook Pro 客户端测量的 0.133 秒慢得多。

最佳答案

使用 Files.walkFileTree 解决了问题API。有了它,我就可以通过一次 SAMBA 网络 IO 调用来获取文件夹中所有文件的所有属性。

关于java - 使用 Java + SAMBA + Win 7 列出文件非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14963927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com