linux - 为什么第二次 cp 命令更快

标签 linux shell caching benchmarking

当我执行 cp folder1 folder2 -rf 时,第一次需要大约 10 分钟。但是当我执行第二个命令 cp folder1 folder3 -rf 时,大约需要 1 分钟。 folder1 包含大约 100 000 个文件。

为什么第二次有运行时间改进?

最佳答案

这是因为页面缓存。运行 sync ; echo 3 >/proc/sys/vm/drop_caches 让它再次变慢。

进一步阅读:

关于linux - 为什么第二次 cp 命令更快,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18056286/

相关文章:

ios - 如何在 Jenkins Groovy 的 ssh 命令中转义美元符号?

java - Infinispan - 根据实体 expiration.lifespan 设置

scala - Spark : understanding the DAG and forcing transformations

c - 在没有堆栈的情况下在 Linux 上进行系统调用

linux - Perl - 自动将用户名和密码添加到 Linux 系统的脚本

regex - 在 bash 中批量文件重命名,删除带空格的名称,留下尾随数字

shell - Jenkins 重启 Tomcat

linux - 如何从安装在 guest VM 上的主机访问 nginx 服务器?

linux - 无需手动输入任何命令

caching - CUDA:什么时候使用共享内存,什么时候依靠L1缓存?