pigpig5442
|
分享:
x0
|
[转帖]一个计算程式执行时间的 Shell Script :
一个计算程式执行时间的 Shell Script :
====================================
#!/bin/sh T1_maj=`date +%s` T1_min=`tcsh -c time | awk '{print $3}' | awk -F: '{print $2}' | awk -F. '{print $2}'`
# ============ Put your Caculating Code ================== sleep 3 # ============ Put your Caculating Code ==================
T2_maj=`date +%s` T2_min=`tcsh -c time | awk '{print $3}' | awk -F: '{print $2}' | awk -F. '{print $2}'`
if [ $T2_min -ge $T1_min ] ; then Td_maj=`expr $T2_maj - $T1_maj` Td_min=`expr $T2_min - $T1_min` else Td_maj=`expr $T2_maj - $T1_maj - 1` Td_min=`expr $T2_min - $T1_min + 100` fi
echo "T1 : $T1_maj.$T1_min"
echo "T2 : $T2_maj.$T2_min"
echo "Td = T2 - T1 : $Td_maj.$Td_min"
[ 此文章被andyz在2005-05-18 20:02重新编辑 ]
|