summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiscomfitor <michael.blumenkrantz@gmail.com>2013-10-01 16:52:52 +0100
committerdiscomfitor <michael.blumenkrantz@gmail.com>2013-10-01 16:52:52 +0100
commitb8814cd12f1ca92b137915e092e94980c3674787 (patch)
treed57e0dadba3c9025c825bc06826ee840bcd5e63d
parent6aca27f5aa6cf514c6937551208b3ba637ccdd3f (diff)
add benchmark scripts
-rwxr-xr-xbat.sh5
-rwxr-xr-xcompbench.sh11
-rwxr-xr-xcpu.sh31
-rwxr-xr-xmem.sh3
4 files changed, 50 insertions, 0 deletions
diff --git a/bat.sh b/bat.sh
new file mode 100755
index 0000000..197a9df
--- /dev/null
+++ b/bat.sh
@@ -0,0 +1,5 @@
1#!/bin/bash
2while true ; do
3 cat /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/PNP0C0A:00/power_supply/BAT1/charge_now
4 sleep 1
5done
diff --git a/compbench.sh b/compbench.sh
new file mode 100755
index 0000000..276c345
--- /dev/null
+++ b/compbench.sh
@@ -0,0 +1,11 @@
1#!/bin/bash
2
3name=$1
4./compbench $2 &> /dev/null &
5comp_pid=$!
6
7(./cpu.sh > ${name}_cpu.log) &
8(./mem.sh > ${name}_mem.log) &
9(./bat.sh > ${name}_bat.log) &
10
11wait $comp_pid
diff --git a/cpu.sh b/cpu.sh
new file mode 100755
index 0000000..1360c7d
--- /dev/null
+++ b/cpu.sh
@@ -0,0 +1,31 @@
1#!/bin/bash
2# from http://colby.id.au/calculating-cpu-usage-from-proc-stat
3# by Paul Colby (http://colby.id.au), no rights reserved ;)
4
5PREV_TOTAL=0
6PREV_IDLE=0
7
8while true; do
9 CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics.
10 unset CPU[0] # Discard the "cpu" prefix.
11 IDLE=${CPU[4]} # Get the idle CPU time.
12
13 # Calculate the total CPU time.
14 TOTAL=0
15 for VALUE in "${CPU[@]}"; do
16 let "TOTAL=$TOTAL+$VALUE"
17 done
18
19 # Calculate the CPU usage since we last checked.
20 let "DIFF_IDLE=$IDLE-$PREV_IDLE"
21 let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
22 let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
23 echo "$DIFF_USAGE"
24
25 # Remember the total and idle CPU times for the next check.
26 PREV_TOTAL="$TOTAL"
27 PREV_IDLE="$IDLE"
28
29 # Wait before checking again.
30 sleep 1
31done
diff --git a/mem.sh b/mem.sh
new file mode 100755
index 0000000..796ed3e
--- /dev/null
+++ b/mem.sh
@@ -0,0 +1,3 @@
1#!/bin/bash
2
3vmstat 1