标签:
time用于统计命令执行花费的总时间
例一:
[root@Director usr]# time ls bin etc games include java lib lib64 libexec local sbin share src tmp real 0m0.004s user 0m0.001s sys 0m0.002s
例二,比较不同算法所花费的时间差异
root@Director test]# time for i in `seq 1111`;do count=${#i};done real 0m0.036s user 0m0.024s sys 0m0.021s [root@Director test]# time for i in `seq 1111`;do count=`echo $i|wc -m`;done real 0m5.985s user 0m1.618s sys 0m5.729s [root@Director test]# time for i in `seq 1111`;do count=`expr length $i`;done real 0m3.938s user 0m1.163s sys 0m3.225s
从中可以看出采用${#var}这种算法最优
标签:
原文地址:http://www.cnblogs.com/zydev/p/5745126.html