zoukankan      html  css  js  c++  java
  • linux计算命令的执行时间

    有时候为了达到同一结果,但有多种不同的办法能够执行,因此想要了解不同命令执行,哪个使用CPU、内存、时间最少

    实现方法

    time #time 后面直接跟命令即可
    -v: 显示更加详细信息

    示例

    1. 统计运行时间
    ]# time touch {1..100}.txt
    
    

    1. 统计运行时间结果重定向-使用子shell"() &>/path/to/info.txt"
    ]# (time for i in `ls /data/images/`;do find /data -type f -name "$i"|xargs rm -f;done) &> /data/info.txt
    ]# cat /data/info.txt
    
    real	0m0.194s
    user	0m0.033s
    sys	0m0.158s
    

    1. 统计运行时间结果重定向-使用"{ time <command>; } &>/path/to/info.txt"

    注意花括号中的空格和分号

    ]# { time find ./ -name "*.txt" ;} &>/data/info.txt
    ]# cat /data/info.txt
    ... #省略
    ./99.txt
    ./100.txt
    
    real	0m0.001s
    user	0m0.001s
    sys	0m0.000s
    

  • 相关阅读:
    Leon-ai on WSL
    自动化测试工具
    创建自己的Spring Boot Starter
    Spring Boot内嵌Tomcat session超时问题
    Spring Boot
    Spring Cloud
    Socket编程之Tomcat模拟_采坑汇总
    访问者模式
    模版模式
    策略模式
  • 原文地址:https://www.cnblogs.com/wanwz/p/12808909.html
Copyright © 2011-2022 走看看