Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- dpv(){ command dpv -k -b "$0" -p "$items\n" -t "$*" -a "\nCombinations:" \
- -l "$total: "; }
- items=
- for deck in 1 2; do
- for card in A 2 3 4 5 6 7 8 9 10 J Q K; do
- for suit in S H C D; do
- items="$items $card$suit$deck"
- done
- done
- done
- items="${items# }"
- total=$( cmb -tk5 $items )
- start=$( date +%s )
- trap exit SIGINT
- clear
- cmb -k5 $items | dpv cmb
- end=$( date +%s )
- elapsed1=$(( $end - $start ))
- seventh=$(( $total / 7 ))
- export items
- start=$( date +%s )
- time echo \
- :$seventh \
- $(( $seventh + 1 )):$seventh \
- $(( $seventh * 2 + 1 )):$seventh \
- $(( $seventh * 3 + 1 )):$seventh \
- $(( $seventh * 4 + 1 )):$seventh \
- $(( $seventh * 5 + 1 )):$seventh \
- $(( $seventh * 6 + 1 )): \
- | xargs -P7 -n1 sh -c '
- start=${1%%:*} count=${1#*:}
- cmb -k5 ${start:+-i$start} ${count:+-c$count} $items
- ' sh | dpv "xargs -P7 cmb"
- end=$( date +%s )
- elapsed2=$(( $end - $start ))
- echo
- awk -v e1=$elapsed1 -v e2=$elapsed2 'BEGIN {
- printf "cmb: %us xargs: %us opt: %.2fx\n", e1, e2, e1 / (e2 || 1)
- }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement