use shell arithmetic expansion
use shell arithmetic expansion

This is way faster than invoking bc repeatedly.

Before:

  $ DATA=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
  $ time spark.old $DATA >/dev/null
  real    0m1.018s
  user    0m0.020s
  sys     0m0.060s

After:

  $ time spark $DATA >/dev/null
  real    0m0.089s
  user    0m0.000s
  sys     0m0.008s

Or to make it more clear:

  $ elapsed_ms() {
      /usr/bin/time -f %e "$@" 2>&1 >/dev/null |
        perl -lpe '$_ *= 1000'
    }
  $ spark "$(elapsed_ms spark.old $DATA),$(elapsed_ms spark $DATA)"
  ▇▁

holman/spark,gwern/spark,naveenkr/spark,lildude/spark