]> arthur.barton.de Git - 7zip-bench.git/blob - 7zip-bench.sh
Add .gitignore, ignore result text files
[7zip-bench.git] / 7zip-bench.sh
1 #!/bin/sh
2
3 # Intro ...
4 echo "This script tries to benchmark your machine using 7-zip, by calling"
5 echo "the \"7za b\" command. See <https://s1.hoffart.de/7zip-bench/> for"
6 echo "existing results. It generates an \"result file\" that is suitable"
7 echo "for submission to the site mentioned above, but you have to do this"
8 echo "on your own, there is NO automatic submission."
9 echo
10 echo "Please make sure that your machine is \"mostly idle\"!"
11 echo "All commands run will be shown below."
12 echo
13
14 # Check prerequisites
15 if ! command -v "7za" >/dev/null 2>&1; then
16         echo "Command \"$1\" not found - please install 7-Zip first!" >&2
17         exit 1
18 fi
19
20 # Check & create "result file" ...
21 RESULT_FILE="$(uname -n)-7zip-bench.txt"
22 if [ -e "$RESULT_FILE" ]; then
23         echo "Result file \"$RESULT_FILE\" already exists. Aborting!" >&2
24         exit 1
25 fi
26
27 # Confirmation ...
28 echo "Ready to go? Hit CTRL-C if not!"
29 for i in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do
30         printf "\033[2K\r(%s)" "$i"
31         sleep 1
32 done
33 printf "\033[2K\n"
34
35 echo "------------------------------------------------------------------------------" >"$RESULT_FILE"
36 set -ex
37
38 {
39         uname -a
40         7za b
41         echo
42         case "$(uname)" in
43           "Darwin")
44                 sysctl hw.model hw.memsize hw.machine hw.ncpu machdep.cpu.brand_string
45                 sw_vers
46                 ;;
47           "Linux")
48                 free
49                 cat /proc/cpuinfo
50                 ;;
51         esac
52 } >>"$RESULT_FILE"
53
54 set +x
55 echo "------------------------------------------------------------------------------" >>"$RESULT_FILE"
56 echo
57
58 echo "Results are:"
59 less "$RESULT_FILE"
60
61 echo
62 echo "Please send the results stored in \"$RESULT_FILE\""
63 echo "to Goetz Hoffart for inclusion on <https://s1.hoffart.de/7zip-bench/>."
64 echo
65 if command -v "sendfile" >/dev/null 2>&1; then
66         echo "For example by running this command:"
67         echo; echo "  sendfile \"$RESULT_FILE\" goetz@s1.hoffart.de"; echo
68 fi
69 echo "You can send it via email to:"
70 echo; echo "  bench@hoffart.de"; echo
71 echo "Thanks a lot!"
72 exit 0