History

added bench tools

Paul Brossier committed 21 years ago

Commit 4cc9fe51 parent 3ec9d9c8 files · +185 −0Browse files

Showing the changes to python (8 of 8 files). Show all

Unified · Split

8 files
  1. python/aubio/bench/__init__.py +0 −0
  2. python/aubio/bench/broadcast.py +25 −0
  3. python/aubio/bench/config.py +21 −0
  4. python/aubio/bench/node.py +48 −0
  5. python/bench-cluster-test +9 −0
  6. python/bench-onset +35 −0
  7. python/bench-pitch +34 −0
  8. python/bench-test +13 −0
python/aubio/bench/__init__.py+0−0

Empty file added.

python/aubio/bench/broadcast.py+25−0
@@ -0,0 +1,25 @@
1from config import *
2
3class run_broadcast:
4 def __init__(self,command,*args):
5 for host in REMOTEHOSTS:
6 command(host,args[0],args[1:])
7
8def remote_sync(host,path='',options=''):
9 optstring = ''
10 for i in options:
11 optstring = "%s %s" % (optstring,i)
12 print RSYNC_CMD,optstring,RSYNC_OPT,' --delete',
13 print '%s%s%s%s%s' % (path,'/ ',host,':',path)
14
15
16def fetch_results(host,path='',options=''):
17 optstring = ''
18 for i in options:
19 optstring = "%s %s" % (optstring,i)
20 print RSYNC_CMD,optstring,RSYNC_OPT,' --update',
21 print '%s%s%s%s%s' % (host,':',path,'/ ',path)
22
23def remote_queue(host,command,options=''):
24 print 'oarsub -p "hostname = \'',host,'\'',command
25
python/aubio/bench/config.py+21−0
@@ -0,0 +1,21 @@
1
2filefound = 0
3try:
4 filename = "/etc/aubio-bench.conf"
5 execfile(filename)
6 filefound = 1
7except IOError:
8 print "no system wide configuration file found in", filename
9
10try:
11 import os
12 filename = "%s%s%s" % (os.getenv('HOME'),os.sep,".aubio-bench.conf")
13 execfile(filename)
14 filefound = 1
15except IOError:
16 print "no user configuration file found in", filename
17
18if filefound == 0:
19 import sys
20 print "error: no configuration file found at all"
21 sys.exit(1)
python/aubio/bench/node.py+48−0
@@ -0,0 +1,48 @@
1from config import *
2import commands,sys
3import re
4
5def runcommand(cmd,debug=0):
6 if VERBOSE >= VERBOSE_CMD or debug: print cmd
7 if debug: return
8 status, output = commands.getstatusoutput(cmd)
9 if status == 0 or VERBOSE >= VERBOSE_OUT:
10 output = output.split('\n')
11 if VERBOSE >= VERBOSE_OUT:
12 for i in output:
13 if i: print i
14 if not status == 0:
15 print 'error:',status,output
16 print 'command returning error was',cmd
17 sys.exit(1)
18 return output
19
20def list_files(datapath,filter='f'):
21 cmd = '%s%s%s%s' % ('find ',datapath,' -type ',filter)
22 return runcommand(cmd)
23
24def mkdir(path):
25 cmd = '%s%s' % ('mkdir -p ',path)
26 return runcommand(cmd)
27
28def act_on_data (action,datapath,respath,suffix='.txt',filter='f'):
29 """ execute action(datafile,resfile) on all files in datapath """
30 dirlist = list_files(datapath,filter=filter)
31 respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:]
32 if(respath_in_datapath and suffix == ''):
33 print 'error: respath in datapath and no suffix used'
34 sys.exit(1)
35 for i in dirlist:
36 s = re.split(datapath, i,maxsplit=1)[1]
37 j = "%s%s%s%s"%(respath,'/',s,suffix)
38 action(i,j)
39
40def act_on_results (action,datapath,respath,filter='d'):
41 """ execute action(respath) an all subdirectories in respath """
42 dirlist = list_files(datapath,filter='d')
43 respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:]
44 if(respath_in_datapath and not filter == 'd' and suffix == ''):
45 print 'warning: respath is in datapath'
46 for i in dirlist:
47 s = re.split(datapath, i ,maxsplit=1)[1]
48 action("%s%s%s"%(respath,'/',s))
python/bench-cluster-test+9−0
@@ -0,0 +1,9 @@
1#! /usr/bin/python
2
3from aubio.bench.broadcast import *
4
5run_broadcast(remote_sync,'/home/testing')
6run_broadcast(remote_sync,'/home/testing','-n')
7run_broadcast(fetch_results,'/home/testing','-n')
8
9run_broadcast(remote_queue,'echo coucou')
python/bench-onset+35−0
@@ -0,0 +1,35 @@
1#! /usr/bin/python
2
3from aubio.bench.config import *
4from aubio.bench.node import *
5
6datapath = "%s%s" % (DATADIR,'/onset/DB')
7respath = '/var/tmp/DB-testings'
8
9MODES = 'hfc', 'complexdomain', 'energy', 'phase', 'specdiff', 'kl', 'mkl'
10THRESHOLD = range(1,14,1)
11
12# prepareresultpath
13act_on_results(mkdir,datapath,respath,filter='d')
14
15def compute_data(input,output):
16 aubiocmd = "%s%s %s%s" % \
17 ("LD_LIBRARY_PATH=",LD_LIBRARY_PATH,AUBIOHOME,"/examples/aubioonset")
18 for m in MODES:
19 for k in THRESHOLD:
20 cmd = "%s --input \"%s\" --onset %s --threshold %s > \"%s--%s--%s.txt\"" \
21 % (aubiocmd,input,m,k/10.,output,m,k/10.)
22 runcommand(cmd,debug=1)
23
24
25# computedata
26act_on_data(compute_data,datapath,respath,suffix='',filter='f -name \'*.wav\'')
27
28# gatherdata
29#act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'')
30# gatherthreshold
31# gathermodes
32# comparediffs
33# gatherdiffs
34
35
python/bench-pitch+34−0
@@ -0,0 +1,34 @@
1#! /usr/bin/python
2
3#from conf.aubio_benchrc import *
4from aubio.bench.config import *
5from aubio.bench.node import *
6import os
7
8datapath = "%s%s" % (DATADIR,'/pitch/isolated/piano/011pfnof')
9respath = '/var/tmp/isolated/testing'
10
11MODES = 'yin', 'mcomb', 'fcomb', 'schmitt'
12
13# prepareresultpath
14act_on_results(mkdir,datapath,respath,filter='d')
15
16def compute_data(input,output):
17 aubiocmd = "%s%s %s%s" % \
18 ("LD_LIBRARY_PATH=",LD_LIBRARY_PATH,AUBIOHOME,"/python/aubiopitch")
19 for m in MODES:
20 cmd = "%s --input \"%s\" --mode %s --verbose --units midi > \"%s--%s.txt\"" \
21 % (aubiocmd,input,m,output,m)
22 runcommand(cmd,debug=0)
23
24
25# computedata
26act_on_data(compute_data,datapath,respath,suffix='',filter='f -name \'*.wav\'')
27
28# gatherdata
29#act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'')
30# gatherthreshold
31# gathermodes
32# comparediffs
33# gatherdiffs
34
python/bench-test+13−0
@@ -0,0 +1,13 @@
1#! /usr/bin/python
2
3from aubio.bench.node import *
4
5datapath = '/var/www'
6respath = '/var/tmp'
7
8def my_print(input,output):
9 cmd = "%s %s %s" % ("time sleep 0.3; echo",input,output)
10 return runcommand(cmd,debug=0)
11
12act_on_results(mkdir,datapath,respath,filter='d')
13act_on_data(my_print,datapath,respath,suffix='.txt')

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t