Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ "$EUID" -ne 0 ]
  4. then
  5. echo "root privilege is required. re-run this script with 'sudo'." >&2
  6. exit 1
  7. fi
  8.  
  9. TEMP_PATH=$(tempfile -d $(pwd))
  10.  
  11. function clear_cache {
  12. /sbin/sysctl -w vm.drop_caches=3 > /dev/null 2>&1
  13. }
  14.  
  15. function test_write {
  16. clear_cache
  17. sync
  18. dd if=/dev/zero of=$TEMP_PATH bs=5M count=256
  19. sync
  20. }
  21.  
  22. function test_read {
  23. clear_cache
  24. sync
  25. dd if=$TEMP_PATH of=/dev/null bs=5M count=256
  26. sync
  27. }
  28.  
  29. echo -e "measuring write speed...\c"
  30. WRITE_SPEED=$(test_write 2>&1 | grep copied | rev | cut -d ' ' -f 1-2 | rev)
  31. echo -e "\rmeasuring write speed... $WRITE_SPEED"
  32. echo -e "measuring read speed...\c"
  33. READ_SPEED=$(test_read 2>&1 | grep copied | rev | cut -d ' ' -f 1-2 | rev)
  34. echo -e "\rmeasuring read speed... $READ_SPEED"
  35. rm -rf $TEMP_PATH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement