例如,有许多用于右移位的LC3汇编程序,根据程序的运行速度来评估它们有意义吗?有没有一种方法可以将汇编程序嵌入到python等脚本语言中来测量其速度?
发布于 2020-12-29 23:07:06
It can be measured indirectly via running a script:
1: create a script for lc3sim denoted as: lc3_run.txt
#cat lc3_run.txt
file test.obj
c
#
2. create a shell script denoted as: perf_test.sh
#cat perf_test.sh
set -x
n=0
while [ $n -lt 1000 ]
do
lc3sim -s lc3_run.txt
((n+=1))
echo $n
done
#chmod +x perf_test.sh
#time ./perf_test.sh
real 0m14.512s
user 0m3.552s
sys 0m3.304s
#3. compare the run time to evaluate which one is faster under
same conditions (HW/SW)
For related reference: <a href="https://softwareengineering.stackexchange.com/questions/357146/how-to-evaluate-efficiency-of-assembler-code "/> efficiency </a>https://stackoverflow.com/questions/65469375
复制相似问题