-
-
Save centminmod/f0fc3515d97fc933b1ffb5a77d3ffee3 to your computer and use it in GitHub Desktop.
zram benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ # /tmp/zramtest3.sh test6 /tmp/ffmpeg-1\:2.6.1-1-x86_64.pkg.tar | |
zram test6 Sat Apr 4 09:50:06 GMT 2015 | |
comp_algorithm [lzo] lz4 snappy | |
real 0m 0.20s 0.20s 0.24s avg: 0.214s | |
real 0m 1.45s 1.42s 1.42s avg: 1.430s | |
compr_data_size 30504972 30504968 30504947 30504962 | |
comp_algorithm lzo [lz4] snappy | |
real 0m 0.21s 0.21s 0.23s avg: 0.217s | |
real 0m 1.36s 1.36s 1.33s avg: 1.350s | |
compr_data_size 31234729 31234719 31234736 31234728 | |
comp_algorithm lzo lz4 [snappy] | |
real 0m 0.22s 0.21s 0.21s avg: 0.214s | |
real 0m 1.56s 1.59s 1.56s avg: 1.570s | |
compr_data_size 30931116 30931087 30931076 30931093 | |
Summary | |
Total average time | |
lzo: 1.644s | |
lz4: 1.567s | |
snappy: 1.784s | |
Average compr_data_size | |
lzo: 30504962 | |
lz4: 31234728 | |
snappy: 30931093 | |
Gain | |
time= 4.7 % (lz4 vs lzo) | |
compression= 2.3% (lzo vs lz4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ # /tmp/zramtest3.sh test6 /tmp/ffmpeg-1\:2.6.1-1-x86_64.pkg.tar | |
zram test6 Sat Apr 4 09:50:06 GMT 2015 | |
comp_algorithm [lzo] lz4 snappy | |
real 0m 0.20s 0.20s 0.24s avg: 0.214s | |
real 0m 1.45s 1.42s 1.42s avg: 1.430s | |
compr_data_size 30504972 30504968 30504947 30504962 | |
comp_algorithm lzo [lz4] snappy | |
real 0m 0.21s 0.21s 0.23s avg: 0.217s | |
real 0m 1.36s 1.36s 1.33s avg: 1.350s | |
compr_data_size 31234729 31234719 31234736 31234728 | |
comp_algorithm lzo lz4 [snappy] | |
real 0m 0.22s 0.21s 0.21s avg: 0.214s | |
real 0m 1.56s 1.59s 1.56s avg: 1.570s | |
compr_data_size 30931116 30931087 30931076 30931093 | |
Summary | |
Total average time | |
lzo: 1.644s | |
lz4: 1.567s | |
snappy: 1.784s | |
Average compr_data_size | |
lzo: 30504962 | |
lz4: 31234728 | |
snappy: 30931093 | |
Gain | |
time= 4.7 % (lz4 vs lzo) | |
compression= 2.3% (lzo vs lz4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/sbin/sh | |
sys_zram="/sys/block/zram0" | |
zram="/dev/block/zram0" | |
disksize="$((50*1024*1024))" | |
mnt_point="zram0mnt" | |
TEST_1="cp -f $2 /${mnt_point}" | |
reset(){ | |
echo 1 > ${sys_zram}/reset | |
sleep 2 | |
} | |
init_disk(){ | |
mkdir -p ${mnt_point} | |
echo ${disksize} > ${sys_zram}/disksize | |
mke2fs -t ext4 -m 0 -I 128 -O ^has_journal,^ext_attr ${zram} >& /dev/null | |
mount -o noatime,barrier=0,data=writeback,nobh,discard ${zram} ${mnt_point} | |
cd ${mnt_point} | |
} | |
case $1 in | |
test1) | |
TEST="time tar xJf $2" | |
;; | |
test2) | |
TEST="time tar xf $2" | |
;; | |
test3) | |
TEST="time cp $2 ." | |
;; | |
test4) | |
TEST="${TEST_1}" | |
TEST_2="time cp -rf /${mnt_point}/ /tmp/" | |
;; | |
test5) | |
TEST="${TEST_1}" | |
TEST_2="time tar -xf /${mnt_point}/*.tar -C /tmp/" | |
;; | |
test6) | |
TEST="time ${TEST_1}" | |
TEST_2="time tar -xf /${mnt_point}/*.tar" | |
;; | |
*) | |
exit | |
;; | |
esac | |
benchmark(){ | |
init_disk | |
${TEST} && ${TEST_2} | |
sync | |
sleep 5 | |
echo 3 > /proc/sys/vm/drop_caches | |
sleep 5 | |
if [ "$1" \< "test3" ] | [ "$1" = "test6" ]; then | |
echo -ne "orig_data_size\t" | cat - ${sys_zram}/orig_data_size | |
echo -ne "compr_data_size\t" | cat - ${sys_zram}/compr_data_size | |
echo -ne "mem_used_total\t" | cat - ${sys_zram}/mem_used_total | |
fi | |
cd .. | |
umount ${mnt_point} | |
reset | |
echo "" | |
} | |
streams_test(){ | |
if [ -e ${sys_zram}/max_comp_streams ] && [ -n "$2" ] && [ "$2" != 0 ]; then | |
for i in $(seq 1 $2) | |
do | |
echo $i > ${sys_zram}/max_comp_streams | |
echo -ne "max_comp_streams\t" | cat - ${sys_zram}/max_comp_streams | |
benchmark $1 | |
done | |
else | |
benchmark $1 | |
fi | |
} | |
comp_algorithm(){ | |
for c in $(cat ${sys_zram}/comp_algorithm | sed -e s#'\['#''#g -e s#'\]'#''#g) | |
do | |
echo $c > ${sys_zram}/comp_algorithm | |
echo -ne "\ncomp_algorithm\t" | cat - ${sys_zram}/comp_algorithm | |
streams_test $1 $2 | |
done | |
} | |
echo -e "zram $1\t" $(date) | |
reset | |
if [ -e ${sys_zram}/comp_algorithm ]; then | |
comp_algorithm $1 $3 | |
else | |
streams_test $1 $3 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment