This is an old revision of the document!


Benchmarking process / IO / latency

links:

 apt-get install contest dbench stress tiobench latencytop

FIXME

http://lbs.sourceforge.net/

Unix Benchmarking

see: http://www.webhostingtalk.com/showthread.php?s=&threadid=308055
Download: UnixBench v4.1.0 - WHT Variant

 # gunzip -dvc unixbench-4.1.0-wht.tar.gz | tar xvf -
 # cd unixbench-4.1.0-wht
 # make
 # ./Run

Please download and run it on your dedicated or VPS. Then post your result here for discussion. Thanks!

IO test

/--(a@tbox)-(Tue Oct 21 15:28:24 CEST 2008)-(0)--
\--(#!:~/src)-- python iotest-2008-10-15 /dev/sda3
/dev/sda3, 23 GB, 512B blocks: 66.1 IOs/s, 33 kB/s
/dev/sda3, 23 GB, 1024B blocks: 65.7 IOs/s, 65 kB/s
/dev/sda3, 23 GB, 2 kB blocks: 64.9 IOs/s, 129 kB/s
...

f iotest-2008-10-15.py

#!/usr/bin/env python
#
# Copyright (c) 2008 Benjamin Schweizer. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
#   * Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#   * Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the
#     distribution.
#   * Neither the name of Benjamin Schweizer nor the names of its
#     contributors may be used to endorse or promote products derived
#     from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# Abstract
# ~~~~~~~~
# Benchmark disk IOs
#
# Authors
# ~~~~~~~
# Benjamin Schweizer, http://benjamin-schweizer.de/contact
#
# Changes
# ~~~~~~~
# 2008-10-16, benjamin: initial release
#
# Todo
# ~~~~
# - we'll see
#

import sys
import random
import time

def usage():
    print """Copyright (c) 2008 Benjamin Schweizer. All rights reserved.

usage:

    iostat <device> [time]

    device  := some block device
    time    := time in seconds

example:

    iostat /dev/sda

"""


def greek(size):
    """Return a string representing the greek/metric suffix of a size"""
    # Copyright (c) 1999 Martin Pohl, copied from
    # http://mail.python.org/pipermail/python-list/1999-December/018519.html
    _abbrevs = [
        (1<<50L, ' P'),
        (1<<40L, ' T'), 
        (1<<30L, ' G'), 
        (1<<20L, ' M'), 
        (1<<10L, ' k'),
        (1, '')
    ]

    for factor, suffix in _abbrevs:
        if size > factor:
            break

    return `int(size/factor)` + suffix


def iotest(dev, blocksize=512, t=10):
    """io test"""
    fh = open(dev, 'r')
    bof = 0
    fh.seek(0,2)
    eof = fh.tell()

    io_num = 0
    start_ts = time.time()
    while time.time() < start_ts+t:
        io_num += 1
        pos = random.randint(bof,eof)
        fh.seek(pos)
        blockdata = fh.read(blocksize)
    end_ts = time.time()

    total_ts = end_ts - start_ts

    print "%s, %sB, %sB blocks: %.1f IOs/s, %sB/s" % (dev, greek(eof), greek(blocksize), io_num/total_ts, greek(int(blocksize*io_num/total_ts)))

    return io_num/total_ts

if __name__ == '__main__':
    if len(sys.argv) < 2:
        usage()
        raise SystemExit

    device = sys.argv[1]
    t = 10
    if len(sys.argv) == 3:
        t = int(sys.argv[2])

    blocksize = 512
    try:
        iops = 2
        while iops > 1:
            iops = iotest(device, blocksize, t)
            blocksize *= 2
    except IOError, (err_no, err_str):
        raise SystemExit(err_str)
    except KeyboardInterrupt:
        print "caught ctrl-c, bye."

# eof.
linux/benchmark.1237462731.txt.gz · Last modified: 2009/05/25 00:34 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready