I suspect your interactive shell is bash or zsh where time is a keyword.
And your script is a sh script (where sh is not based on bash, ksh nor zsh) where time is /usr/bin/time which would only time the echo command above.
Just do:
echo ... | time"time" bc ...
as it's really bc you want to get the execution time of here.
Quoting time here makes sure it's not treated as a keyword in shells that have a time keyword.