3 ms·
for i in $(seq 1 20); do (run once and emit the total CPU time) done |addup "Here we don't actually care about the output (we never actuall
by 3xblah 7y ago
for i in $(seq 1 20); do
(run once and emit the total CPU time)
done |addup
"Here we don't actually care about the output (we never actually use $i) but it's a convenient way to get the for loop to run twenty times."
This is slower than not running seq and just using builtins.
n=1;while true;do
test $n -le 20||break;
(run once and emit the total CPU time)
n=$((n+1));
done |addup
- deathanatos 7y agoThe author did say convenient, not fast. If you don't want the inefficiencies of seq, bash has: for (( expr1 ; expr2 ; expr3 )) ; do list ; done which is a lot more idiomatic than constructing a for loop out of a while loop.
- pimlottc 7y agoYou could also just use a bash brace expansion: for i in {1..20} do ... done https://wiki.bash-hackers.org/syntax/expansion/brace https://wiki.bash-hackers.org/syntax/expansion/brace
- deleted 7y ago[deleted]
- 3xblah 7y agoThe author refers to "the shell" in his "benchmark" but if he is a Linux user then sh -c 'f 11 access.2020-01-* ... is dash whereas f 11 access.2020-01* ... is bash Needless to say, one of these shells is much faster than the other and only one contains the "time" builtin command. https://wiki.ubuntu.com/DashAsBinSh https://wiki.ubuntu.com/DashAsBinSh Then there is the use of perl and its system command in "count". As with seq, why is perl needed. No explanation. Why not just put the entire pipeline into a perl system command.