(test-it.sh)
2010-12-15 17:48
169 查看
#!/bin/sh
# Verify whether the directory of JavaScript Cases is inputted.
if [ $# -lt 1 ];then
echo "Please specify the directory of JavaScript Cases!"
exit
fi
# Verify whether the inputted directory exists.
if [ ! -d $1 ];then
echo "$1 does not exist!"
exit
fi
CURRENT_DIR=`dirname $0`
JSC_JIT=`echo "${CURRENT_DIR}/jsc_jit"`
JSC_NO_JIT=`echo "${CURRENT_DIR}/jsc_no_jit"`
# Verify whether the jsc with jit exists
if [ ! -f ${JSC_JIT} ];then
echo "JSC with JIT does not exist!"
exit
fi
# Verify whether the jsc without jit exists
if [ ! -f ${JSC_NO_JIT} ];then
echo "JSC without JIT does not exist!"
exit
fi
SUM=0
OK=0
NG=0
LOG=it-test.log
> $LOG
# Search each *.js file in the specified directory.
JS_FILES=`find $1 -name "*.vert"`
# Test each JS file with jsc_jit and jsc_no_jit.
echo "" | tee -a $LOG
DATE=`date`
echo "Test time:$DATE" | tee -a $LOG
for JS in $JS_FILES
do
BYTE_CODE_SIZE=0
MACHINE_CODE_SIZE=0
MAX_MACHINE_CODE_SIZE=0
echo "Testing ${JS} ..." | tee -a $LOG
echo -e "var stime = new Date();/n" > case.js
cat ${JS} >> case.js
echo -e "var etime = new Date();/nprint(/"Duration is:/", etime-stime);/n" >> case.js
# Get executive time of case with jsc_jit
${JSC_JIT} case.js &> tmp
# Get the executive time
TIME_JIT=`cat tmp | grep "Duration" | awk -F: '{print $2}'`
# Get the compilation time
compile_times=`cat tmp | grep "Compilation Time(ms)" | awk -F: '{print $2}'`
loop=`echo $compile_times | wc -l`
all_compile_time=0
# Get the sum of all time
for compile_time in $compile_times
do
all_compile_time=`expr ${all_compile_time} + ${compile_time}`
done
# Calculate byte code size
SIZES=`cat tmp | grep "Byte Code Size(byte):" | awk -F: '{print $2}'`
for SIZE in ${SIZES}
do
BYTE_CODE_SIZE=`expr ${BYTE_CODE_SIZE} + ${SIZE}`
done
# Calculate machine code size
SIZES=`cat tmp | grep "Machine Code Size(byte):" | awk -F: '{print $2}'`
for SIZE in ${SIZES}
do
MACHINE_CODE_SIZE=`expr ${MACHINE_CODE_SIZE} + ${SIZE}`
if [ ${SIZE} -gt ${MAX_MACHINE_CODE_SIZE} ]
then
MAX_MACHINE_CODE_SIZE=${SIZE}
fi
done
# Get memory usage
MEM_USAGE=`cat tmp | grep "heap total" | awk '{print $6 $9 $12}'`
HEAP_TOTAL=`echo $MEM_USAGE | awk -F, '{print $1}'`
HEAP_PEAK=`echo $MEM_USAGE | awk -F, '{print $2}'`
STACK_PEAK=`echo $MEM_USAGE | awk -F, '{print $3}'`
# Get executive time of case with jsc_no_jit
TIME_NO_JIT=`${JSC_NO_JIT} case.js | grep "Duration" | awk -F: '{print $2}'`
echo "Running Time (ms)" | tee -a $LOG
printf "Used JIT :%8d/n" ${TIME_JIT} | tee -a $LOG
printf "Unused JIT :%8d/n" ${TIME_NO_JIT} | tee -a $LOG
printf "Compiling Time (ms) :%8d/n" ${all_compile_time} | tee -a $LOG
printf "Byte Code Size(byte) :%8d/n" ${BYTE_CODE_SIZE} | tee -a $LOG
printf "Machine Code Size(byte) :%8d/n" ${MACHINE_CODE_SIZE} | tee -a $LOG
printf "Max Machine Code Size(byte):%8d/n" ${MAX_MACHINE_CODE_SIZE} | tee -a $LOG
echo "Memory usage(byte)" | tee -a $LOG
printf "Heap total :%8d/n" ${HEAP_TOTAL} | tee -a $LOG
printf "Heap peak :%8d/n" ${HEAP_PEAK} | tee -a $LOG
printf "Stack peak :%8d/n" ${STACK_PEAK} | tee -a $LOG
echo "*************************************************************" | tee -a $LOG
echo "" | tee -a $LOG
rm case.js
if [ -z ${TIME_JIT} ];then
NG=`expr $NG + 1`
else
OK=`expr $OK + 1`
fi
SUM=`expr $SUM + 1`
done
echo "----------------------------" | tee -a $LOG
printf "TOTAL NUMBER:%3d/n" $SUM | tee -a $LOG
printf "OK NUMBER :%3d/n" $OK | tee -a $LOG
printf "NG NUMBER :%3d/n" $NG | tee -a $LOG
echo "----------------------------" | tee -a $LOG
echo "" | tee -a $LOG
rm tmp -rf
# Verify whether the directory of JavaScript Cases is inputted.
if [ $# -lt 1 ];then
echo "Please specify the directory of JavaScript Cases!"
exit
fi
# Verify whether the inputted directory exists.
if [ ! -d $1 ];then
echo "$1 does not exist!"
exit
fi
CURRENT_DIR=`dirname $0`
JSC_JIT=`echo "${CURRENT_DIR}/jsc_jit"`
JSC_NO_JIT=`echo "${CURRENT_DIR}/jsc_no_jit"`
# Verify whether the jsc with jit exists
if [ ! -f ${JSC_JIT} ];then
echo "JSC with JIT does not exist!"
exit
fi
# Verify whether the jsc without jit exists
if [ ! -f ${JSC_NO_JIT} ];then
echo "JSC without JIT does not exist!"
exit
fi
SUM=0
OK=0
NG=0
LOG=it-test.log
> $LOG
# Search each *.js file in the specified directory.
JS_FILES=`find $1 -name "*.vert"`
# Test each JS file with jsc_jit and jsc_no_jit.
echo "" | tee -a $LOG
DATE=`date`
echo "Test time:$DATE" | tee -a $LOG
for JS in $JS_FILES
do
BYTE_CODE_SIZE=0
MACHINE_CODE_SIZE=0
MAX_MACHINE_CODE_SIZE=0
echo "Testing ${JS} ..." | tee -a $LOG
echo -e "var stime = new Date();/n" > case.js
cat ${JS} >> case.js
echo -e "var etime = new Date();/nprint(/"Duration is:/", etime-stime);/n" >> case.js
# Get executive time of case with jsc_jit
${JSC_JIT} case.js &> tmp
# Get the executive time
TIME_JIT=`cat tmp | grep "Duration" | awk -F: '{print $2}'`
# Get the compilation time
compile_times=`cat tmp | grep "Compilation Time(ms)" | awk -F: '{print $2}'`
loop=`echo $compile_times | wc -l`
all_compile_time=0
# Get the sum of all time
for compile_time in $compile_times
do
all_compile_time=`expr ${all_compile_time} + ${compile_time}`
done
# Calculate byte code size
SIZES=`cat tmp | grep "Byte Code Size(byte):" | awk -F: '{print $2}'`
for SIZE in ${SIZES}
do
BYTE_CODE_SIZE=`expr ${BYTE_CODE_SIZE} + ${SIZE}`
done
# Calculate machine code size
SIZES=`cat tmp | grep "Machine Code Size(byte):" | awk -F: '{print $2}'`
for SIZE in ${SIZES}
do
MACHINE_CODE_SIZE=`expr ${MACHINE_CODE_SIZE} + ${SIZE}`
if [ ${SIZE} -gt ${MAX_MACHINE_CODE_SIZE} ]
then
MAX_MACHINE_CODE_SIZE=${SIZE}
fi
done
# Get memory usage
MEM_USAGE=`cat tmp | grep "heap total" | awk '{print $6 $9 $12}'`
HEAP_TOTAL=`echo $MEM_USAGE | awk -F, '{print $1}'`
HEAP_PEAK=`echo $MEM_USAGE | awk -F, '{print $2}'`
STACK_PEAK=`echo $MEM_USAGE | awk -F, '{print $3}'`
# Get executive time of case with jsc_no_jit
TIME_NO_JIT=`${JSC_NO_JIT} case.js | grep "Duration" | awk -F: '{print $2}'`
echo "Running Time (ms)" | tee -a $LOG
printf "Used JIT :%8d/n" ${TIME_JIT} | tee -a $LOG
printf "Unused JIT :%8d/n" ${TIME_NO_JIT} | tee -a $LOG
printf "Compiling Time (ms) :%8d/n" ${all_compile_time} | tee -a $LOG
printf "Byte Code Size(byte) :%8d/n" ${BYTE_CODE_SIZE} | tee -a $LOG
printf "Machine Code Size(byte) :%8d/n" ${MACHINE_CODE_SIZE} | tee -a $LOG
printf "Max Machine Code Size(byte):%8d/n" ${MAX_MACHINE_CODE_SIZE} | tee -a $LOG
echo "Memory usage(byte)" | tee -a $LOG
printf "Heap total :%8d/n" ${HEAP_TOTAL} | tee -a $LOG
printf "Heap peak :%8d/n" ${HEAP_PEAK} | tee -a $LOG
printf "Stack peak :%8d/n" ${STACK_PEAK} | tee -a $LOG
echo "*************************************************************" | tee -a $LOG
echo "" | tee -a $LOG
rm case.js
if [ -z ${TIME_JIT} ];then
NG=`expr $NG + 1`
else
OK=`expr $OK + 1`
fi
SUM=`expr $SUM + 1`
done
echo "----------------------------" | tee -a $LOG
printf "TOTAL NUMBER:%3d/n" $SUM | tee -a $LOG
printf "OK NUMBER :%3d/n" $OK | tee -a $LOG
printf "NG NUMBER :%3d/n" $NG | tee -a $LOG
echo "----------------------------" | tee -a $LOG
echo "" | tee -a $LOG
rm tmp -rf
相关文章推荐
- It's just a test!
- shell test_case.sh
- 一段查询自身是否已在运行的脚本test.sh,有些要注意到地方
- 找到出问题的位置---test it
- pc端的企业网站(IT修真院test8)详解1-4
- glusterfs volume create: testvol: failed: /data/brick1 or a prefix of it is already part of a volume
- test_if.sh
- Unreal 4 TestDemo Error Log for Mac Start->RocketBuild.sh failed with exit code 5
- IT'S MY FIRST BLOG JUST TO DO TEST! HaHa
- java.sql.SQLException: Created a new connection but it failed its test
- ./test.sh: 3: ./test.sh: Syntax error: "(" unexpected
- test-definitions/blob/master/auto-test/golang/golang.sh
- pc端的企业网站(IT修真院test8)详解1-3
- It is just a test.
- PHP Warning: strftime(): It is not safe to rely on the system's timezone testlink
- test_while.sh
- -bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory
- 执行查询报: Incorrect key file for table ‘test’; try to repair it
- It's a test
- test-definitions/blob/master/auto-test/httperf-client/httperf.sh