From: Paul Brossier Date: Wed, 24 Aug 2005 00:52:49 +0000 (+0000) Subject: added bench tools X-Git-Tag: 0.4.0-beta1~1358 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=4cc9fe5d89c4e4281cf9015429bd92e9773c1ea1;p=aubio.git added bench tools --- diff --git a/python/aubio/bench/__init__.py b/python/aubio/bench/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/aubio/bench/broadcast.py b/python/aubio/bench/broadcast.py new file mode 100644 index 00000000..95ec2f83 --- /dev/null +++ b/python/aubio/bench/broadcast.py @@ -0,0 +1,25 @@ +from config import * + +class run_broadcast: + def __init__(self,command,*args): + for host in REMOTEHOSTS: + command(host,args[0],args[1:]) + +def remote_sync(host,path='',options=''): + optstring = '' + for i in options: + optstring = "%s %s" % (optstring,i) + print RSYNC_CMD,optstring,RSYNC_OPT,' --delete', + print '%s%s%s%s%s' % (path,'/ ',host,':',path) + + +def fetch_results(host,path='',options=''): + optstring = '' + for i in options: + optstring = "%s %s" % (optstring,i) + print RSYNC_CMD,optstring,RSYNC_OPT,' --update', + print '%s%s%s%s%s' % (host,':',path,'/ ',path) + +def remote_queue(host,command,options=''): + print 'oarsub -p "hostname = \'',host,'\'',command + diff --git a/python/aubio/bench/config.py b/python/aubio/bench/config.py new file mode 100644 index 00000000..edc580b8 --- /dev/null +++ b/python/aubio/bench/config.py @@ -0,0 +1,21 @@ + +filefound = 0 +try: + filename = "/etc/aubio-bench.conf" + execfile(filename) + filefound = 1 +except IOError: + print "no system wide configuration file found in", filename + +try: + import os + filename = "%s%s%s" % (os.getenv('HOME'),os.sep,".aubio-bench.conf") + execfile(filename) + filefound = 1 +except IOError: + print "no user configuration file found in", filename + +if filefound == 0: + import sys + print "error: no configuration file found at all" + sys.exit(1) diff --git a/python/aubio/bench/node.py b/python/aubio/bench/node.py new file mode 100644 index 00000000..cc18bc09 --- /dev/null +++ b/python/aubio/bench/node.py @@ -0,0 +1,48 @@ +from config import * +import commands,sys +import re + +def runcommand(cmd,debug=0): + if VERBOSE >= VERBOSE_CMD or debug: print cmd + if debug: return + status, output = commands.getstatusoutput(cmd) + if status == 0 or VERBOSE >= VERBOSE_OUT: + output = output.split('\n') + if VERBOSE >= VERBOSE_OUT: + for i in output: + if i: print i + if not status == 0: + print 'error:',status,output + print 'command returning error was',cmd + sys.exit(1) + return output + +def list_files(datapath,filter='f'): + cmd = '%s%s%s%s' % ('find ',datapath,' -type ',filter) + return runcommand(cmd) + +def mkdir(path): + cmd = '%s%s' % ('mkdir -p ',path) + return runcommand(cmd) + +def act_on_data (action,datapath,respath,suffix='.txt',filter='f'): + """ execute action(datafile,resfile) on all files in datapath """ + dirlist = list_files(datapath,filter=filter) + respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:] + if(respath_in_datapath and suffix == ''): + print 'error: respath in datapath and no suffix used' + sys.exit(1) + for i in dirlist: + s = re.split(datapath, i,maxsplit=1)[1] + j = "%s%s%s%s"%(respath,'/',s,suffix) + action(i,j) + +def act_on_results (action,datapath,respath,filter='d'): + """ execute action(respath) an all subdirectories in respath """ + dirlist = list_files(datapath,filter='d') + respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:] + if(respath_in_datapath and not filter == 'd' and suffix == ''): + print 'warning: respath is in datapath' + for i in dirlist: + s = re.split(datapath, i ,maxsplit=1)[1] + action("%s%s%s"%(respath,'/',s)) diff --git a/python/bench-cluster-test b/python/bench-cluster-test new file mode 100755 index 00000000..7afd4796 --- /dev/null +++ b/python/bench-cluster-test @@ -0,0 +1,9 @@ +#! /usr/bin/python + +from aubio.bench.broadcast import * + +run_broadcast(remote_sync,'/home/testing') +run_broadcast(remote_sync,'/home/testing','-n') +run_broadcast(fetch_results,'/home/testing','-n') + +run_broadcast(remote_queue,'echo coucou') diff --git a/python/bench-onset b/python/bench-onset new file mode 100755 index 00000000..e76955d9 --- /dev/null +++ b/python/bench-onset @@ -0,0 +1,35 @@ +#! /usr/bin/python + +from aubio.bench.config import * +from aubio.bench.node import * + +datapath = "%s%s" % (DATADIR,'/onset/DB') +respath = '/var/tmp/DB-testings' + +MODES = 'hfc', 'complexdomain', 'energy', 'phase', 'specdiff', 'kl', 'mkl' +THRESHOLD = range(1,14,1) + +# prepareresultpath +act_on_results(mkdir,datapath,respath,filter='d') + +def compute_data(input,output): + aubiocmd = "%s%s %s%s" % \ + ("LD_LIBRARY_PATH=",LD_LIBRARY_PATH,AUBIOHOME,"/examples/aubioonset") + for m in MODES: + for k in THRESHOLD: + cmd = "%s --input \"%s\" --onset %s --threshold %s > \"%s--%s--%s.txt\"" \ + % (aubiocmd,input,m,k/10.,output,m,k/10.) + runcommand(cmd,debug=1) + + +# computedata +act_on_data(compute_data,datapath,respath,suffix='',filter='f -name \'*.wav\'') + +# gatherdata +#act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'') +# gatherthreshold +# gathermodes +# comparediffs +# gatherdiffs + + diff --git a/python/bench-pitch b/python/bench-pitch new file mode 100755 index 00000000..cfe81480 --- /dev/null +++ b/python/bench-pitch @@ -0,0 +1,34 @@ +#! /usr/bin/python + +#from conf.aubio_benchrc import * +from aubio.bench.config import * +from aubio.bench.node import * +import os + +datapath = "%s%s" % (DATADIR,'/pitch/isolated/piano/011pfnof') +respath = '/var/tmp/isolated/testing' + +MODES = 'yin', 'mcomb', 'fcomb', 'schmitt' + +# prepareresultpath +act_on_results(mkdir,datapath,respath,filter='d') + +def compute_data(input,output): + aubiocmd = "%s%s %s%s" % \ + ("LD_LIBRARY_PATH=",LD_LIBRARY_PATH,AUBIOHOME,"/python/aubiopitch") + for m in MODES: + cmd = "%s --input \"%s\" --mode %s --verbose --units midi > \"%s--%s.txt\"" \ + % (aubiocmd,input,m,output,m) + runcommand(cmd,debug=0) + + +# computedata +act_on_data(compute_data,datapath,respath,suffix='',filter='f -name \'*.wav\'') + +# gatherdata +#act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'') +# gatherthreshold +# gathermodes +# comparediffs +# gatherdiffs + diff --git a/python/bench-test b/python/bench-test new file mode 100755 index 00000000..ae1f0879 --- /dev/null +++ b/python/bench-test @@ -0,0 +1,13 @@ +#! /usr/bin/python + +from aubio.bench.node import * + +datapath = '/var/www' +respath = '/var/tmp' + +def my_print(input,output): + cmd = "%s %s %s" % ("time sleep 0.3; echo",input,output) + return runcommand(cmd,debug=0) + +act_on_results(mkdir,datapath,respath,filter='d') +act_on_data(my_print,datapath,respath,suffix='.txt')