Open main menu

CDOT Wiki β

Changes

Winter 2009 SYA810 Block Device Benchmark Scripts

6,757 bytes removed, 22:39, 16 July 2012
no edit summary
Please post your block device benchmark script here. I'm looking for a wide range of benchmark methodologies, so your script should test in a different way than the other scripts. I will collect these scripts on '''Monday, Jan 26''' and create a master script which runs all of these tests and reports the overall results.
= John Doe (example) P. Constantino =
Script or link #!/bin/bash # This script generate random numbers and seeks to that POSITION on the block device given, reading 1 kb of data at the time. # The purpose is test the speed of randomly reading 1024(default) blocks of 1KB from the disk. # A valid input for BLOCK DEVICE could be: /dev/sdb (disk) - /dev/sda9 (partition) - /dev/md8 (RAID) - /dev/mapper/foo/bar (LV). echo -n "Enter a number of block to read. Enter for default(1024): " read BLOCKS if [ "$BLOCKS" = "" ] then BLOCKS=1024 fi echo -n "Enter a valid block device (dev/): " read BLOCKDEVICE SIZE=$(df /dev/$BLOCKDEVICE | awk '{print $3}' | grep -v 'Used') time -p for ((x=1; x<=$BLOCKS; x++)) do POSITION=$(( RANDOM % $SIZE + 1)) dd if=/dev/$BLOCKDEVICE of=/dev/null bs=1k count=1 seek=$POSITION sync echo 3 >/proc/sys/vm/drop_caches done echo " ^ time to script goes hereprocess randomly $BLOCKS blocks of 1KB on /dev/$BLOCKDEVICE."
= Gregory Katherine Masseau = [http://matrix.senecac.on.ca/~gjmasseau/DiskTest.py Disk Test Script]
"""= Nestor CHAN = DiskTest.py[http:This script tests a disks write/read performance for both block devices and individual files, presenting it's output as an HTML file contaning a table/matrix.senecac.on.ca/~tnchan/PerformanceTest/ Perfomance Test]
Example invocation= Mohak Vyas =[http:sudo python DiskTest.py D="/dev/sda1" F="zenit.senecac.on.ca/x" -readd -writef -readf -d18 O=/mntwiki/md0index.php/webshare/stuff/out.htmlPerformancescript Performance Test]
To (destructively) write test a block device add the '=Varinder Singh=[http://matrix.senecac.on.ca/~vsjhand/storage/python-writed' option."""scripts/ Python Performance Scripts]
from sys import stdoutverbosity = 2debug = Trueif __name__=="__main__": repeat = 5Script in Python.Any suggestions would be welcome
from os import remove, system
from sys import argv
from time import sleep
from timeit import Timer
def setup(argv):=Kezhong Liang= #!/bin/bash echo """Takes an argument list argv and returns paraters needed for testsStart to test ...""" depth TIME_WRITE_START= list$(set([a[2:] for a in argv if a[0:2] == "-d"])date +%s) disk dd if= list(set([a[2:] for a in argv if a[0:2] /dev/zero of=test bs= "D1024 count="]))1000000 sync scratch TIME_WRITE_END= list$(set([a[2:] for a in argv if a[0:2] == "F="])date +%s) outf = list(set([a[2:] for a in argv if a[0:2] == "O="])) echo 3 > /proc/sys/vm/drop_caches tests = list(set([a[1:] for a in argv if a[1:] in ["readf","readd","writef","writed"]])) sync errors TIME_READ_START= list(set([a for a in argv if a not in $(["-d"+x for x in depth]+["D="+x for x in disk]+["F="+x for x in scratch]+["-"+x for x in tests]+["O="date +x for x in outf]+[argv[0]])])%s) dd if errors or (not(len(disk)=test of=1)) or (not(len(scratch)/dev/null bs=1024 count=1)) or (not(len(depth))1000000 TIME_READ_END==1) or $(not(len(outfdate +%s)) == 1): print rm test echo "USAGE -- "+argv[0]+" D=<disk> F=<scratch file> O=<output> -d<depth> [-readd] [-readf] [-writed] [-writef]-------------------------------------------------" exit TIME_WRITE_USED=$(1) if ("writed" in tests$TIME_WRITE_END - $TIME_WRITE_START): system('clear') print ( echo -n "WARNING!!! "*7)+"\n\nYou have selected the 'The write to disk' test.\nThis test will DESTROY any file system on the device selected (if it is a partition), possibly multiple filesystems if it is an entire disk. \n\nPLEASE DOUBLE CHECK TO ENSURE NO IMPORTANT DATA IS ON THIS DISK PRIOR TO PROCEEDING!\n\nTo proceed with the test, please enter the name of the device whose contents you are about to destroy.\n\n(The test will be aborted if input does not match the disk specified previously.\n\nDeviceperformance:", if echo -n $(not (raw_input() == disk[0]1024 / $TIME_WRITE_USED)): print echo "\nAborting.\n\nMB/sec" exit TIME_READ_USED=$(1($TIME_READ_END - $TIME_READ_START)) else echo -n "The read disk performance: tests.remove("writed") tests.append echo -n $("writed") if ("writef" in tests1024 / $TIME_READ_USED): tests.remove("writef") tests = [ echo "writefMB/sec"]+tests return [disk,scratch,outf,tests,depth]
def time(p): """Runs a test p, returning the time in seconds it took.""" print " - time(%r)\n"%(p,) if debug else "", f,d,s,sf = p importstr = "from "+"".join(argv[0].split(".")[0:-1])+" import "+", ".join(tests) teststr Milton Paiva Neto = stringifyparams(p) timer = Timer(teststr,importstr) print " - timer = Timer('%s','%s')\n"%(teststr,importstr) if debug else "", stdout.write("\nTest: "+teststr if (verbosity==1) else "") time = timer.timeit(repeat) print " - time = %s\n"%time if debug else "", stdout.write("Time: "+("%.3lf"%time)+" seconds.\n" if (verbosity==1) else "") sleep(0.025) return (f,d,s,sf,time)
def stringifyparams(p): #!/bin/bash # # Script first written by Nestor Chan - Bossanesta and modified by Milton Paiva Neto <milton.paiva@gmail.com> """Stringifies a set # Create 10 files with one with 10 GBs fully of test parameters p."""zeros print " time - stringifyparamsp (for ((%rx=1; x<=10; x++)\n"%(p,) do dd if debug else "",=/dev/zero of=fakefile$x bs=1G count=10; func,disk,size,scratchfile = p done sync return "".join([func,"('",disk,"',",("%s"%size),",'",scratchf,"')"] )
def dropextraneous(rs): """Takes a tuple rs and drops uneeded fields.""" print " - dropextraneous(%r)\n"%(rs,) if debug else "", f,d,s,sf,t = rs return [f,s,t]  def group(inp): """Takes a list of lists inp, returning a list of lists grouped by the first element, i.e.: [['a',1,2],['a',2,3],['b',4,5],['b',6,7],['c',3,3]] => [['a', [[1, 2], [2, 3]]], ['b', [[4, 5], [6, 7]]], ['c', [[3, 3]]]] """ print " - group(%r)\n"%inp if debug else "", return __group(sorted(inp),[],[],"") def __group(inp,buf,out,seek): print " - group(%r,%r,%r,'%r')\n"%(inp,out,buf,seek) if debug else "", if (not (inp==[])): inph = inp[0] inpt = inp[1:] inphh = inph[0] inpht = inph[1:] seek = inphh if (seek=="") else seek return out+[[seek,buf]] if (inp==[]) else __group(inpt,buf+[inpht],out,seek) if (seek==inphh) else __group(inpt,[inpht],out+[[seek,buf]],inphh)  def preformat(d): """Adjusts the values returned by the test loop (d) into something suitable for table.""" left = "<table border=1><tr><td>Bytes</td><td>Test</td></tr></table>" right = "<table borderLINKS =1><tr><td>Test</td><td>Bytes</td></tr></table>" colns = (lambda d: [""]+[("<b>%s</b>"%x[0]) for x in d[0][1:][0]]+[""])(d) rowns = (lambda d: [("<b>%s</b>"%x[0]) for x in d])(d) fdata = (lambda dhttp: [["%.3lf s"%x[1] for x in x[1]] for x in d])(d) lol = map(list,zip(*[colns]+[[rowns[x]]+fdata[x]+[rowns[x]] for x in range(0,len(rowns))]+[colns])) height = (lambda x:len(x)-1)(lol) width = (lambda x:len(x[0])-1)(lol) lol[0] [0] = left lol[height][0] = left lol[0] [width] = right lol[height][width] = right return lol  def table(title,lol): """Takes a list of lists lol and a title title, returning as a string an HTML page titled title containing the contents of lol in a table.""" print "table(%r)\n"%lol if debug else "", return "".join(["".join(x) for x in [["<html>\n<center><table><tr><td><center><h3>%s</h3></center></td></tr><tr><td><table border=1>"%title]]+[["\n <tr>"]+["\n <td>%s</td>"%w for w in l]+["\n </tr>"] for l in lol]+[["\n </table></td></tr></table></center>\n</html>"]]])  settings = setup(argv) disks = settings[0] scratchfs = settings[1] outputf = settings[2][0] tests = settings[3] depth = int(settings[4][0])  testparams = [(test,disk,size,scratchf) for test in tests for size in [siz*1024 for siz in [1<<(x-1) for x in range(1,depth)]] for scratchf in scratchfs for disk in disks for depth in [depth]]  OUTFILE = open(outputf,"w") OUTFILE.write(table("Disk Benchmark Results",preformat(group(map((lambda p:dropextraneous(time(p))),testparams))))) OUTFILE.flush() OUTFILE.close()  print "\nDone. Output is in: "+outputf+"."else: from os import SEEK_END from random import randint  def donefile(FILE,tag): """Close a file.""" FILE.flush() print " - donefile(FILE) <-[ %s ]\n"%tag if debug else "", print ' - FILE.close()\n' if debug else "", FILE.close() stdout.write("done.\n" if (verbosity==2) else ""), return True  def writef(disk,size,scratchf): """Do a file write test.""" print " - writef('%s',%d,'%s')\n"%(disk,size,scratchf) if debug else "", randomseek(disk) stdout.write("(D) Writing "+("%s"%size)+" bytes to "+scratchf+"...\n" if (verbosity==2) else ""), FILE = open(scratchf,"w") print ' - FILE.write("xxx"...)\n' if debug else "", FILE.write((lambda x: "".join(["x" for x in range(1,x)]))(size)) donefile(FILE,"writef") return True  def writed(disk,size,scratchf): """Do a disk write test.""" print " - writed('%s',%d,'%s')\n"%(disk,size,scratchf) if debug else "", return writef(disk,size,disk)  def readf(disk,size,scratchf): """Do a file read test.""" print " - readf('%s',%d,'%s')\n"%(disk,size,scratchf) if debug else "", randomseek(disk) print ' - FILE = open(%s),"r"\n'%disk if debug else "", FILE = open(scratchf,"r") FILE.seek(0,0) stdout.write("(D) Reading "+("%s"%size)+" bytes from "+scratchf+"...\n" if (verbosity==2) else "") print ' linux- FILE.read()\n' if debug else "", FILEraid.read(size) if (size < 4194304) else [FILEosdl.read(4194304) for x in range(0,sizeorg/4194304)] donefile(FILE,"readf") return True  def readd(disk,size,scratchf): """Do a file read testindex.""" print " - readd('%s',%d,'%s')\n"%(disk,size,scratchf) if debug else "", return readf(disk,size,disk)  def randomseek(disk): """Seek the disk head to a random position.""" print " - randomseek('%s')\n"%disk if debug else "", jumploc = randint(0,disksize(disk)) stdout.write("Randomizing head position by seeking byte "+("%s"%jumploc)+" of "+disk+"...\n" if (verbosity==2) else "") print ' - FILE = open(%s),"r"\n'%disk if debug else "", FILE = open(disk,"r") FILE.seek(jumploc) donefile(FILE,"randomseek") return True  def disksize(disk): """Get the size of a disk.""" print " - disksize('%s')\n"%disk if debug else "", print ' - FILE = open(%s),"r"\n'%disk if debug else "", FILE = open(disk,"r") FILE.seek(0,SEEK_END) l = FILE.tell() print " - FILE.close()\n" if debug else "", FILE.close() return l  def writef(disk,size,scratchf): """Do a file write test.""" print " - writef('%s',%d,'%s')\n"%(disk,size,scratchf) if debug else "", randomseek(disk) stdout.write("(D) Writing "+("%s"%size)+" bytes to "+scratchf+"...\n" if (verbosity==2) else ""), FILE = open(scratchf,"w") print ' - FILE.write(<%d>)\n'%size if debug else "", [FILE.write('\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa') for x in range(0,sizephp/64)Performance Linux Raid Performance] donefile(FILE,"writef") return True