source: proto/SymbolTable/test/perftest.py @ 1795

Last change on this file since 1795 was 1786, checked in by vla24, 8 years ago

Added some code to support performance tests using PAPI

File size: 1.6 KB
Line 
1from subprocess import *
2import os
3#import config, argparse
4from string import *
5
6#programs = ['xmlwf','expat','Xerces_SAX','Xerces_DOM']
7programs = ['xmlwf']
8testfiles = []
9output_dir = ""
10repeat = 10
11
12def set_test_files(tests):
13    global testfiles
14    testfiles = tests
15
16def set_output_dir(path):
17    global output_dir
18    output_dir = path
19
20def run_test():
21    mes_f = open(output_dir+"mesfile", 'w')
22    for program in programs:
23        for testfile in testfiles:
24            for i in range(repeat):
25                call(['./../src/'+program, testfile], stderr=mes_f)
26    mes_f.close()
27
28def get_filename(path):
29    """Given a string that contains a path, this function will return
30       the filename
31    """
32    filename_start = path.rfind('/')
33    if filename_start == -1:
34        return path
35    return path[filename_start+1:]
36
37def analyze_result():
38    output_str = ""
39
40    mes_f = open(output_dir+"mesfile", 'r')
41    results = mes_f.read().split(' ')
42    mes_f.close()
43    results_int = []
44    rows = {}
45
46    for r in results[:-1]:
47        results_int.append(int(r))
48    first_row = '\t\t'
49
50    for testfile in testfiles:
51        first_row += get_filename(testfile) + '  &\t'
52    first_row =  first_row[:-4]
53    #print first_row
54    output_str = output_str + first_row + '\n'
55
56    for program in programs:
57        row = program + '   &\t'
58        for testfile in testfiles:
59            result = results_int[0:repeat]
60            results_int = results_int[repeat:]
61            row +=  str(min(result)/1000.0) + '   &\t'
62        row = row[:-4]
63        row +='\\\\ \\hline'
64        #print row
65        output_str = output_str + row + '\n'
66
67    return output_str
Note: See TracBrowser for help on using the repository browser.