Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #!/bin/bash
  2. declare -a sorts=("bubble" "insertion" "merge" "quick" "heap")
  3. cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 29 | head -n5 > test_5.txt
  4.  
  5. for((i=10; i<=1000000; i*=10))
  6. do
  7. cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 29 | head -n$i > test_$i.txt
  8. done
  9.  
  10. echo "Number of lines is 5:" >> res.txt
  11. for sort in "${sorts[@]}"
  12. do
  13. valgrind --tool=callgrind --time-stamp=yes --log-file=result.txt ./main 5 test_5.txt $sort
  14. echo $sort: >> res.txt
  15. cat result.txt | grep -E -o '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]' | tail -1 >> res.txt
  16. rm result.txt
  17. done
  18.  
  19. for((i=10; i <= 1000000; i*=10))
  20. do
  21. echo -e "\nNumber of lines is $i:" >> res.txt
  22. for sort in "${sorts[@]}"
  23. do
  24. valgrind --tool=callgrind --time-stamp=yes --log-file=result.txt ./main 5 test_$i.txt $sort
  25. echo $sort: >> res.txt
  26. cat result.txt | grep -E -o '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]' | tail -1 >> res.txt
  27. rm result.txt
  28. done
  29. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement