-1

我一直试图解决这个错误 2 天,但我无法弄清楚错误到底在哪里。你能帮我解决这个小错误吗?

#!/bin/bash

ntests=10
param_vertexes=10
param_pop=10

echo -e "\nExecution of parallel with 8 threads for $ntests times."
par8_time=0
for i in $(seq $ntests); do
    output=$(./parallel -t 8 $param_vertexes $param_pop)
    echo $output
    par8_time=$par8_time+$(echo $output | cut -d' ' -f6)
done
par8_time=$(echo $par8_time | bc)
echo "Total Iteration/Time: $par8_time"
echo "Speedup of 8 threads: $(echo -e "scale=10\n"$par8_time/$seq_time | bc)"

我不断收到同样的错误

Execution of parallel with 8 threads for 10 times.
Sequential iterations / time = 23.642725
Sequential iterations / time = 23.860021
Sequential iterations / time = 23.703970
Sequential iterations / time = 23.513577
Sequential iterations / time = 23.728710
Sequential iterations / time = 23.790608
Sequential iterations / time = 23.590524
Sequential iterations / time = 23.612470
Sequential iterations / time = 23.653072
Sequential iterations / time = 23.675878
Total Iteration/Time: 236.771555
   (standard_in) 3: syntax error
   Speedup of 8 threads: 

如您所见,我的脚本的唯一问题是syntax error它不允许脚本显示加速因子。

有任何想法吗?提前致谢。

4

2 回答 2

1

您从未设置过seq_time,因此试图评估的表达式bc是“236.771555/”,这会产生语法错误。

于 2013-04-28T23:29:44.947 回答
0

尝试这个:

a=$(echo -e "scale=10;$par8_time/$seq_time" | bc)
echo "Speedup of 8 threads: $a"
于 2013-04-28T22:42:09.710 回答