Changeset 3461


Ignore:
Timestamp:
Sep 11, 2013, 1:11:33 PM (6 years ago)
Author:
cameron
Message:

Add escaping of quotes in pattern, some additional cases.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/performance/perf.py

    r3409 r3461  
    66import sys
    77import shutil
     8
    89
    910def execute(execution):
     
    4748
    4849
     50def escape_quotes(e):  return e.replace("'", "'\\''")
    4951
    5052
     
    5557        log_file.close()
    5658        redirectoutput= ' 2>&1 | tee '+outputpath+'/output.txt >> perflog.txt'
    57         if execution.program=='bitstreams':
    58                
     59        if execution.program=='bitstreams':             
    5960                re_home = '../'
    6061                re_input_file = open(re_home+'input/test/test1.re', 'w')
     
    6970                p.wait()
    7071        if execution.program=='grep':
    71                 cmd = ['perf stat -x, -o perfoutput -r '+str(count)+' -e '+ execution.stat+ ' grep -c -E \'' + execution.expression.expression + '\' '+ execution.file.file + redirectoutput]
     72                escaped_e = escape_quotes(execution.expression.expression)
     73                cmd = ['perf stat -x, -o perfoutput -r '+str(count)+' -e '+ execution.stat+ ' grep -c -E \'' + escaped_e + '\' '+ execution.file.file + redirectoutput]
    7274                p = Popen(cmd,shell=True)
    7375                p.wait()
     
    7678                e = execution.expression.expression
    7779                if nrgrep_override.has_key(e): e = nrgrep_override[e]
     80                e = escape_quotes(e)
    7881                cmd = ['perf stat -x, -o perfoutput -r '+str(count)+' -e '+ execution.stat+ ' '+nrgreplocation+' -c \'' + e + '\' '+ execution.file.file + redirectoutput]
    7982                p = Popen(cmd,shell=True)
     
    8184        if execution.program=='nrgrep':
    8285                nrgreplocation='nrgrep-1.0/nrgrep'
    83                 e = execution.expression.expression
    8486                if nrgrep_override.has_key(e): e = nrgrep_override[e]
     87                e = escape_quotes(e)
    8588                cmd = ['perf stat -x, -o perfoutput -r '+str(count)+' -e '+ execution.stat+ ' '+nrgreplocation+' -c \'' + e + '\' '+ execution.file.file + redirectoutput]
    8689                p = Popen(cmd,shell=True)
     
    8891        if execution.program=='pcregrep':
    8992                pcregreplocation='pcre-8.12/pcregrep'
    90                 cmd = ['perf stat -x, -o perfoutput -r '+str(count)+' -e '+ execution.stat+ ' '+pcregreplocation+' -c  \'' + execution.expression.expression + '\' '+ execution.file.file + redirectoutput]
     93                e = escape_quotes(execution.expression.expression)
     94                cmd = ['perf stat -x, -o perfoutput -r '+str(count)+' -e '+ execution.stat+ ' '+pcregreplocation+' -c  \'' + e + '\' '+ execution.file.file + redirectoutput]
    9195                p = Popen(cmd,shell=True)
    9296                p.wait()
     
    9599                e = execution.expression.expression
    96100                if agrep_override.has_key(e): e = agrep_override[e]
     101                e = escape_quotes(e)
    97102                cmd = ['perf stat -x, -o perfoutput -r '+str(count)+' -e '+ execution.stat+ ' '+agreplocation+' -0 -c \'' + e + '\' '+ execution.file.file + redirectoutput]
    98103                p = Popen(cmd,shell=True)
     
    114119executions = []
    115120Execution = namedtuple('Execution', ['stat', 'program', 'file', 'expression'])
    116 
    117 
    118 
    119 
    120 
    121121
    122122#http://sljit.sourceforge.net/regex_perf.html
     
    166166agrep_override['([^ @]+)@([^ @]+)'] = '([^ @][^ @]*)@([^ @][^ @]*)'
    167167agrep_override['([a-zA-Z][a-zA-Z0-9]*)://([^ /]+)(/[^ ]*)?|([^ @]+)@([^ @]+)'] = '([a-zA-Z][a-zA-Z0-9]*)://([^ /][^ /]*)(/[^ ]*)?|([^ @][^ @]*)@([^ @][^ @]*)'
     168agrep_override['[0-9]+[.][0-9]+, *[0-9]+[.][0-9]+'] = '[0-9][0-9]*[.][0-9][0-9]*\, *[0-9][0-9]*[.][0-9][0-9]*'
    168169
    169170
     
    176177
    177178
     179files.append(File('../../../trunk/QA/TD/roads-2.gml', 'roads', ('gml',)))
     180expressions.append(Expression('<!--([^-]|-[^-])*-->', 'comment', ('gml',)))
     181expressions.append(Expression('<[^!?][^>]*>', 'tag', ('gml',)))
     182expressions.append(Expression('<gml:[^>]* xmlns:gml="[^"]*"[^>]*>', 'xmlns:gml', ('gml',)))
     183expressions.append(Expression('[0-9]+[.][0-9]+, *[0-9]+[.][0-9]+', 'coord', ('gml',)))
     184expressions.append(Expression(r"""["']|&quot;|&apos;|&#0*3[49];|&#x0*2[27];""", 'xquote', ('gml',)))
     185
     186
     187expressions.append(Expression('(^|[^A-Z0-9:])([A-F0-9]{1,4}:){7}[A-F0-9]{1,4}($|[^A-Z0-9:])', 'IPv6', ('reb',)))
     188
    178189programs = ['bitstreams','agrep', 'nrgrep112', 'grep', 'pcregrep']
    179 stats = ['cycles:u', 'instructions:u', 'cache-misses:u', 'L1-dcache-load-misses:u', 'L1-dcache-store-misses:u', 'L1-dcache-prefetch-misses:u', 'L1-icache-load-misses:u']
     190#programs = ['bitstreams','grep']
     191#programs = ['bitstreams']
     192
     193#stats = ['cycles:u', 'instructions:u', 'cache-misses:u', 'L1-dcache-load-misses:u', 'L1-dcache-store-misses:u', 'L1-dcache-prefetch-misses:u', 'L1-icache-load-misses:u']
     194stats = ['cycles:u']
    180195
    181196typeargument=False
Note: See TracChangeset for help on using the changeset viewer.