android_emmc_perf_tests.sh revision ecb600d0d9de4eacfd619dfe380a94af1abee0dd
1#!/bin/bash
2
3PERF="rand_emmc_perf"
4
5if [ ! -r "$PERF" ]
6then
7  echo "Cannot read $PERF test binary"
8fi
9
10if ! adb shell true >/dev/null 2>&1
11then
12  echo "No device detected over adb"
13fi
14
15HARDWARE=`adb shell getprop ro.hardware | tr -d "\r"`
16
17case "$HARDWARE" in
18  tuna | steelhead)
19    CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
20    CACHE="/dev/block/platform/omap/omap_hsmmc.0/by-name/cache"
21    MMCDEV="mmcblk0"
22    ;;
23
24  stingray | wingray)
25    CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
26    CACHE="/dev/block/platform/sdhci-tegra.3/by-name/cache"
27    MMCDEV="mmcblk0"
28    ;;
29
30  herring)
31    echo "This test will wipe the userdata partition on $HARDWARE devices."
32    read -p "Do you want to proceed? " ANSWER
33
34    if [ "$ANSWER" != "yes" ]
35    then
36      echo "aborting test"
37      exit 1
38    fi
39
40    CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
41    CACHE="/dev/block/platform/s3c-sdhci.0/by-name/userdata"
42    MMCDEV="mmcblk0"
43    ;;
44
45  grouper)
46    CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
47    CACHE="/dev/block/platform/sdhci-tegra.3/by-name/CAC"
48    MMCDEV="mmcblk0"
49    ;;
50
51  manta)
52    CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
53    CACHE="/dev/block/platform/dw_mmc.0/by-name/cache"
54    MMCDEV="mmcblk0"
55    ;;
56
57  *)
58    echo "Unknown hardware $HARDWARE.  Exiting."
59    exit 1
60esac
61
62# prepare the device
63adb root
64adb wait-for-device
65adb push "$PERF" /dev
66adb shell stop
67adb shell stop sdcard
68adb shell stop ril-daemon
69adb shell stop media
70adb shell stop drm
71adb shell stop keystore
72adb shell stop tf_daemon
73adb shell stop bluetoothd
74adb shell stop hciattach
75adb shell stop p2p_supplicant
76adb shell stop wpa_supplicant
77adb shell stop mobicore
78adb shell umount /sdcard >/dev/null 2>&1
79adb shell umount /mnt/shell/sdcard0 >/dev/null 2>&1
80adb shell umount /data >/dev/null 2>&1
81adb shell umount /cache >/dev/null 2>&1
82# Add more services here that other devices need to stop.
83# So far, this list is sufficient for:
84#   Prime
85
86# At this point, the device is quiescent, need to crank up the cpu speed,
87# then run tests
88adb shell "cat $CPUFREQ/cpuinfo_max_freq > $CPUFREQ/scaling_max_freq"
89adb shell "cat $CPUFREQ/cpuinfo_max_freq > $CPUFREQ/scaling_min_freq"
90
91# Start the tests
92
93# Sequential read test
94for I in 1 2 3
95do
96  adb shell "echo 3 > /proc/sys/vm/drop_caches"
97  echo "Sequential read test $I"
98  adb shell dd if="$CACHE" of=/dev/null bs=1048576 count=200
99done
100
101# Sequential write test
102for I in 1 2 3
103do
104  echo "Sequential write test $I"
105  adb shell dd if=/dev/zero of="$CACHE" bs=1048576 count=200
106done
107
108# Random read tests require that we read from a much larger range of offsets
109# into the emmc chip than the write test.  If we only read though 100 Megabytes
110# (and with a read-ahead of 128K), we quickly fill the buffer cache with 100
111# Megabytes of data, and subsequent reads are nearly instantaneous.  Since
112# reading is non-destructive, and we've never shipped a device with less than
113# 8 Gbytes, for this test we read from the raw emmc device, and randomly seek
114# in the first 6 Gbytes.  That is way more memory than any device we currently
115# have and it should keep the cache from being poluted with entries from
116# previous random reads.
117#
118# Also, test with the read-ahead set very low at 4K, and at the default
119
120# Random read test, 4K read-ahead
121ORIG_READAHEAD=`adb shell cat /sys/block/$MMCDEV/queue/read_ahead_kb | tr -d "\r"`
122adb shell "echo 4 > /sys/block/$MMCDEV/queue/read_ahead_kb"
123for I in 1 2 3
124do
125  adb shell "echo 3 > /proc/sys/vm/drop_caches"
126  echo "Random read (4K read-ahead) test $I"
127  adb shell /dev/"$PERF" -r 6000 "/dev/block/$MMCDEV"
128done
129
130# Random read test, default read-ahead
131adb shell "echo $ORIG_READAHEAD > /sys/block/$MMCDEV/queue/read_ahead_kb"
132for I in 1 2 3
133do
134  adb shell "echo 3 > /proc/sys/vm/drop_caches"
135  echo "Random read (default read-ahead of ${ORIG_READAHEAD}K) test $I"
136  adb shell /dev/"$PERF" -r 6000 "/dev/block/$MMCDEV"
137done
138
139# Random write test
140for I in 1 2 3
141do
142  echo "Random write test $I"
143  adb shell /dev/"$PERF" -w 100 "$CACHE"
144done
145
146# Random write test with O_SYNC
147for I in 1 2 3
148do
149  echo "Random write with o_sync test $I"
150  adb shell /dev/"$PERF" -w -o 100 "$CACHE"
151done
152
153# Make a new empty /cache filesystem
154adb shell make_ext4fs "$CACHE"
155
156