?

Log in

No account? Create an account
Linux Community's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Monday, September 7th, 2015

Time Event
9:59p
Why is expansion faster than direct parsing in for loops?
Because existing knowledge is faster than research I thought I'd ask the question here.

time for i in {1..1000}; do echo "I hate Windows 10"; done
real 0m0.021s
user 0m0.011s
sys 0m0.006s

time for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24... etc 996 997 998 999 1000; do echo "I hate Windows 10"; done
real 0m0.161s
user 0m0.125s
sys 0m0.012s

To generate the numbers in the second example
printf "%d " {1..1000}

<< Previous Day 2015/09/07
[Calendar]
Next Day >>
About LiveJournal.com