ref: 4cc9fe5d89c4e4281cf9015429bd92e9773c1ea1
parent: 3ec9d9c8eb76d7d845c0a0145be59186528cc5a7
author: Paul Brossier <piem@altern.org>
date: Tue Aug 23 20:52:49 EDT 2005
added bench tools
--- /dev/null
+++ b/python/aubio/bench/broadcast.py
@@ -1,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
+
--- /dev/null
+++ b/python/aubio/bench/config.py
@@ -1,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)
--- /dev/null
+++ b/python/aubio/bench/node.py
@@ -1,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))
--- /dev/null
+++ b/python/bench-cluster-test
@@ -1,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')
--- /dev/null
+++ b/python/bench-onset
@@ -1,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
+
+
--- /dev/null
+++ b/python/bench-pitch
@@ -1,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
+
--- /dev/null
+++ b/python/bench-test
@@ -1,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')