Advertisement
devinteske

cmb_test2.sh

Nov 12th, 2018
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.84 KB | None | 0 0
  1. #!/bin/sh
  2. dpv(){ command dpv -k -b "$0" -p "$items\n" -t "$*" -a "\nCombinations:" \
  3.     -l "$total: "; }
  4. items="a b c d e f g h i j k l m n o p q r s t u v w x y z"
  5. total=$( cmb -t $items )
  6. start=$( date +%s )
  7. trap exit SIGINT
  8. clear
  9. cmb $items | dpv cmb
  10. end=$( date +%s )
  11. elapsed1=$(( $end - $start ))
  12. sixth=$(( $total / 6 ))
  13. export items
  14. start=$( date +%s )
  15. time echo \
  16.     :$sixth \
  17.     $(( $sixth + 1 )):$sixth \
  18.     $(( $sixth * 2 + 1 )):$sixth \
  19.     $(( $sixth * 3 + 1 )):$sixth \
  20.     $(( $sixth * 4 + 1 )):$sixth \
  21.     $(( $sixth * 5 + 1 )): \
  22.     | xargs -P6 -n1 sh -c '
  23.         start=${1%%:*} count=${1#*:}
  24.         cmb ${start:+-i$start} ${count:+-c$count} $items
  25.     ' sh | dpv "xargs -P6 cmb"
  26. end=$( date +%s )
  27. elapsed2=$(( $end - $start ))
  28. echo
  29. awk -v e1=$elapsed1 -v e2=$elapsed2 'BEGIN {
  30.     printf "cmb: %us   xargs: %us   opt: %.2fx\n", e1, e2, e1 / e2
  31. }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement