summaryrefslogtreecommitdiffhomepage
path: root/bench/fields.sh
blob: 74f1bdf13bfd7d1e582f82d3ff2698a0352c3f6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
# IFS field splitting of one line into positional parameters, 3000 times.
# Setting IFS here is the measurement itself, not a hazard.
list=a:b:c:d:e:f:g:h
i=0
n=0
while [ $i -lt 20000 ]; do
    old=$IFS
    IFS=:
    set -- $list
    IFS=$old
    n=$((n + $#))
    i=$((i + 1))
done
echo "$n"