cleanbrowsing / dnsperftest

DNS Performance test
Other
2.33k stars 279 forks source link

Why did you use BC? #89

Open diasdmhub opened 7 months ago

diasdmhub commented 7 months ago

I've removed the bc and command dependencies and changed the average calculation to pure shell scripting in the hopes of making the script a bit more compatible with limited systems.

Instead of

command -v (...)
(...)
avg=`bc -l <<< "scale=2; $ftime/$totaldomains"`

I changed to

which (...)
(...)
avg=$((100 * ftime / totaldomains))
avg_decimal=$((avg / 100))
avg_remainder=$((avg % 100))
printf "%d.%02d\n" $avg_decimal $avg_remainder

It seems the result is correct.

Why did you use BC after all?