美文网首页
shell 计算代码执行时长

shell 计算代码执行时长

作者: 芮淼一线 | 来源:发表于2022-09-26 13:32 被阅读0次

    代码如下

    #!/usr/bin/env bash 
    
    
    echo 开始时间:$(date)
    start_time=$(date +%s)
    
    
    #执行代码
    
    
    echo 结束时间:$(date)
    end_time=$(date +%s)
    cost_time=$[$end_time - start_time]
    echo "总共耗时:$(($cost_time)) s"
    

    相关文章

      网友评论

          本文标题:shell 计算代码执行时长

          本文链接:https://www.haomeiwen.com/subject/ehztartx.html