加快文件系统访问速度?

编程入门 行业动态 更新时间:2024-10-23 22:24:46
本文介绍了加快文件系统访问速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的应用会扫描文件系统的一部分,我的用户在扫描网络驱动器时报告说它非常慢。测试我的代码,我发现了瓶颈:方法 File.isFile(), File.isDirectory(),以及 File.isHidden(),它们都在调用 fs.getBooleanAttributes(File f)。在Windows网络驱动器上,此方法似乎非常慢。如何提高性能?我可以避免以某种方式调用此方法吗?

My app scans part of a file system, and my users reported it was very slow when they were scanning a network drive. Testing my code, I identified the bottleneck: the methods File.isFile(), File.isDirectory(), and File.isHidden(), which are all calling fs.getBooleanAttributes(File f). This method appears to be very slow on Windows network drives. How can I improve performance? Can I avoid calling this method in some way?

推荐答案

您是如何构建此文件列表的?除非您同时显示系统中的每个文件,否则您应该有一些选项...

How are you building this file list? Unless you are displaying every file on the system at the same time, you should have some options...

  • 仅在处理此信息时用户要求它。例如他们点击文件夹Windows,此时你可以在Windows中处理文件。
  • 在后台线程中处理这些信息,给人一种更好的响应时间的假象。
  • 也许如果您展示用于构建列表的代码,我们可以找到其他一些改进的方面。 (为什么不能根据用于收集信息的方法推断出类型?如果你正在调用像GetFiles()这样的方法,你不知道返回的所有内容都是文件吗?)

    Perhaps if you show the code you are using to build the list, we could find some other areas of improvement. (Why can't you just infer the type based on the method used to gather the information? If you're calling a method like GetFiles() don't you already know that everything returned is a file?)

    更多推荐

    加快文件系统访问速度?

    本文发布于:2023-10-31 18:45:01,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1546954.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:文件系统   访问速度

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!