Changeset 3543 for proto


Ignore:
Timestamp:
Oct 29, 2013, 5:35:44 PM (6 years ago)
Author:
shiyangy
Message:

script updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/xmlschema/src/perf.py

    r3541 r3543  
    1313n1,n2 = shiporder_gen.gen(10000,11100,10,12)
    1414
     15perfin = open("perflog.txt",'r')
     16perfout = open("st.txt",'w')
     17
     18perfout.write('total byte:'+str(n1)+'\n')
     19perfout.write('data byte:'+str(n2)+'\n')
     20perfout.write('data percetage:'+str(float(n2)/n1)+'\n\n')
     21
     22def read_log(filename):
     23        perfin = open(filename,'r')
     24        for i in range(6):
     25                line = perfin.readline()
     26        ls = line.split(' ')
     27#       print ls
     28        for i in ls:
     29                if len(i) >0 :
     30                        break
     31        ls2 = i.split(',')
     32#       print ls2
     33        cycle = 0
     34        for j in range(len(ls2)):
     35                cycle *= 1000
     36                cycle += int(ls2[j])
     37#       print cycle
     38        line = perfin.readline()
     39        ls = line.split(' ')
     40        for i in ls:
     41                if len(i) >0 :
     42                        break
     43        ls2 = i.split(',')
     44#       print ls2
     45        instruction = 0
     46        for j in range(len(ls2)):
     47                instruction *= 1000
     48                instruction += int(ls2[j])
     49#       print instruction
     50        return cycle,instruction
     51
     52#read_log("perflog.txt")
     53
     54def print_st(perfout,cy,ins):
     55        perfout.write('cycles:'+str(cy)+'\n')
     56        perfout.write('instructions:'+str(ins)+'\n')
     57        perfout.write('cycles per byte:'+str(float(cy)/n1)+'\n')
     58        perfout.write('instructions per byte:'+str(float(ins)/n1)+'\n')
     59        perfout.write('\n\n')
     60
    1561def execute(execution,count):
    1662        #parabix parsing only
    17         cmd = ['perf stat -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out > ../s.out']
     63        cmd = ['perf stat -o perflog.txt -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out > ../s.out']
    1864        p = Popen(cmd,shell=True)
    1965        p.wait()
     66        cy,ins = read_log("perflog.txt")
     67        perfout.write('parabix parsing only\n')
     68        print_st(perfout,cy,ins)
    2069        #parsing and symbol table processing
    21         cmd = ['perf stat -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -s > ../s.out']
     70        cmd = ['perf stat -o perflog.txt -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -s > ../s.out']
    2271        p = Popen(cmd,shell=True)
    2372        p.wait()
     73        cy,ins = read_log("perflog.txt")
     74        perfout.write('symbol table\n')
     75        print_st(perfout,cy,ins)
    2476        #parsing and symbol table processing and datatype validation
    25         cmd = ['perf stat -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -d > ../s.out']
     77        cmd = ['perf stat -o perflog.txt -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -d > ../s.out']
    2678        p = Popen(cmd,shell=True)
    2779        p.wait()
     80        cy,ins = read_log("perflog.txt")
     81        perfout.write('datatype with symbol table\n')
     82        print_st(perfout,cy,ins)
    2883        #parsing and symbol table processing and content model validation
    29         cmd = ['perf stat -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -c > ../s.out']
     84        cmd = ['perf stat -o perflog.txt -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -c > ../s.out']
    3085        p = Popen(cmd,shell=True)
    3186        p.wait()
     87        cy,ins = read_log("perflog.txt")
     88        perfout.write('content model with symbol\n')
     89        print_st(perfout,cy,ins)
    3290        #all
    33         cmd = ['perf stat -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -a > ../s.out']
     91        cmd = ['perf stat -o perflog.txt -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -a > ../s.out']
    3492        p = Popen(cmd,shell=True)
    3593        p.wait()
     94        cy,ins = read_log("perflog.txt")
     95        perfout.write('all\n')
     96        print_st(perfout,cy,ins)
    3697        #for datatype validation, without validation, just gathering
    37         cmd = ['perf stat -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -g > ../s.out']
     98        cmd = ['perf stat -o perflog.txt -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -g > ../s.out']
    3899        p = Popen(cmd,shell=True)
    39100        p.wait()
     101        cy,ins = read_log("perflog.txt")
     102        perfout.write('datatype without validation, just gathering\n')
     103        print_st(perfout,cy,ins)
    40104        #for content model validation, without validating
    41         cmd = ['perf stat -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -v > ../s.out']
     105        cmd = ['perf stat -o perflog.txt -e cycles,instructions -r ' +str(count) +' '+ './xmlwf ' + execution.file +' xml.out -v > ../s.out']
    42106        p = Popen(cmd,shell=True)
    43107        p.wait()
     108        cy,ins = read_log("perflog.txt")
     109        perfout.write('content model without validation, just gathering')
     110        print_st(perfout,cy,ins)
    44111       
    45112Execution = namedtuple('Execution',['file'])
     
    49116execute(execution1,10)
    50117
     118
     119
    51120print n1
    52121print n2
Note: See TracChangeset for help on using the changeset viewer.