Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- iterations=100
- echo 'generating long string...'
- long=$(hexdump -n100000 -e '"%x"' /dev/urandom)
- echo 'doing != and = unquoted ...'
- time sh <<EOF
- l='$long'
- for i in \$(seq 1 $iterations); do [ \$l != '' -o \$l = '' ]; done
- EOF
- echo 'doing != and = "quoted" ...'
- time sh <<EOF
- l='$long'
- for i in \$(seq 1 $iterations); do [ "\$l" != '' -o "\$l" = '' ]; done
- EOF
- echo 'doing -z and -n...'
- time sh <<EOF
- l='$long'
- for i in \$(seq 1 $iterations); do [ -z "\$l" -o -n "\$l" ]; done
- EOF
- echo 'doing double test [ -n ] || [ -z ] ...'
- time sh <<EOF
- l='$long'
- for i in \$(seq 1 $iterations); do [ -n "\$l" ] || [ -z "\$l" ]; done
- EOF
- echo 'doing ${#}'
- time sh <<EOF
- l='$long'
- for i in \$(seq 1 $iterations); do [ \${#l} -ne 0 -o \${#l} -eq 0 ]; done
- EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement