time命令的问题

sh/bash/dash/ksh/zsh等Shell脚本
回复
heyangya
帖子: 10
注册时间: 2010-02-27 9:40

time命令的问题

#1

帖子 heyangya » 2010-03-02 21:31

#!/bin/bash
tf1="testfile1"
tf2="testfile2"
tf3="testfile3"
tp1="./method_one"
tp2="./method_two"
tp3="./method_three"
size1="1"
size2="256"
size3="16*1024"
time -o testreslut ${tp1} ${size1} ${tf1}
time -a testresult ${tp1} ${size1} ${tf2}

运行后:
heyangya@heyangya-laptop:~/task1$ ./test
./test: line 11: -o:找不到命令

real 0m0.001s
user 0m0.000s
sys 0m0.000s
./test: line 12: -a:找不到命令

real 0m0.001s
user 0m0.004s
sys 0m0.004s

这是为什么呢?
还有,我怎么才能在shell中得到time的结果呢,要测试三次然后求平均值。。。
头像
cnchyan
帖子: 106
注册时间: 2005-06-19 23:33

Re: time命令的问题

#2

帖子 cnchyan » 2010-03-03 0:34

man time

Users of the bash shell need to use an explicit path in order to run
the external time command and not the shell builtin variant.
Ubuntu Karmic
acer 5595 : core2 duo T7200;2*1024M DDR2-667 ;intel 965pm;ati mobility readon X1600

贫贱不能移,富贵不能淫,威武不能屈
heyangya
帖子: 10
注册时间: 2010-02-27 9:40

Re: time命令的问题

#3

帖子 heyangya » 2010-03-03 11:12

谢谢,这个解决了。。。
还有个问题,怎么设置得到的结果的精确度呢?默认的只有两位小数,但我要四位,请问怎么设置呢?
回复