分页: 1 / 1

time命令的问题

发表于 : 2010-03-02 21:31
heyangya
#!/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的结果呢,要测试三次然后求平均值。。。

Re: time命令的问题

发表于 : 2010-03-03 0:34
cnchyan
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.

Re: time命令的问题

发表于 : 2010-03-03 11:12
heyangya
谢谢,这个解决了。。。
还有个问题,怎么设置得到的结果的精确度呢?默认的只有两位小数,但我要四位,请问怎么设置呢?