DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Linux Benchmarking


Some Theory

  • http://stackoverflow.com/questions/368472/linux-benchmarking-tools

  • Linux Benchmarking HOWTO.

Tools

Disk IO Benchmark

Writing Speed

$ dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync

from Simple Disk Benchmarking in Linux Using 'dd'

Reading Speed

$ hdparm -tT $(df $HOME|awk 'FNR == 2 {print $1}')

where "df $HOME|awk 'FNR == 2 {print $1}'" get the disk name of the $HOME folder. For example, on my laptop it is /dev/sda1, on 49 server it is /dev/mapper/vg_bocoty49-lv_root. In awk command, "FNR == 2" means the second line. This is the "origin" version:

$ hdparm -tT /dev/sda

from How to Test the Read and Write Speeds of a Hard Disk in Linux.

Another reference: https://wiki.archlinux.org/index.php/Hdparm

Network Throughput Benchmark

Run the following command on the "server" host, not the "client" host which is testd.

$ cat testspeed.sh

filesize=$3
dd bs=1M count=$filesize if=/dev/zero of=test
timeres=$(/usr/bin/time -p scp test $1@$2:/home/$1/ 2>&1 >/dev/null)
echo timeres: $timeres
duration=$(echo $timeres|awk 'FNR == 1 {print $2}')
echo duration: $duration
speed=$(echo "scale=2; $filesize / $duration" | bc -l)
echo $speed MB/s

The output format of "time" and "bc" command varies depending on distro of OS, so I only implements above on my OS: Linux Mint 14. The "-p" options give a better output format of this command. The output of "scp" is in stdout, while that of "time" in stderr, so I hide stdout and redirect stderr to stdout, so the output can be processed by the following "awk". "bc -l" do a float division instead of a integer division. "scale=2" set the division scale (precision) to 2 digits after the period.

Run this scprit with a 64MB test file:

$ ./speed.sh chad 10.0.2.49 64

Now with a 128MB test file:

$ ./testspeed.sh 128

Note: iperf is network throughput tool, but it has to be installed. So it's a little complicated.



Published

Apr 8, 2014

Last Updated

Apr 8, 2014

Category

Tech

Tags

  • benchmark 4
  • Linux 158

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor