See the following run time comparison. {1..1000000} is slower than
$(seq 1000000).

Since seq involves an external program, I'd expect the latter to be
slower. But the comparison shows the opposite.

I guess seq did some optimization?

Can the performance of {1..1000000} be improved so that it is faster
than $(seq 1000000)?

$ time builtin printf %.sx {1..1000000}  > /dev/null

real    0m2.614s
user    0m2.361s
sys     0m0.166s
$ time builtin printf %.sx $(seq 1000000)  > /dev/null

real    0m1.516s
user    0m1.317s
sys     0m0.158s

-- 
Regards,
Peng

Reply via email to