source: proto/SymbolTable/src/perf_script_wcd.py @ 4881

Last change on this file since 4881 was 1794, checked in by vla24, 8 years ago

updated wcd performance script

File size: 1.8 KB
Line 
1from subprocess import *
2import os
3from string import *
4import run_wcd
5
6testfile_home = "../test/test_files/"
7#programs = ['wcd']
8#TODO: Change the testfiles
9dictionaryfiles = ['wcd_the_mansion.txt', 'wcd_alice_in_wonderland.txt', 'wcd_pride_and_prejudice.txt']
10testfiles = ['wcd_the_republic_by_plato.txt', 'wcd_tale_of_two_cities.txt', 'wcd_a_sailor_of_king_george.txt', 'wcd_metamorphosis.txt', 'wcd_bio_papers.txt']
11repeat = 10
12
13def run_test():     
14  mes_f = open('mesfile', 'w')
15  for dictionary in dictionaryfiles:
16    dictionary_path = testfile_home+dictionary
17    # convert files to lowercase
18    dictionary_new_path = run_wcd.convert_file_to_lowercase(dictionary_path)
19
20    for text in testfiles:
21      text_path = testfile_home+text
22      # convert files to lowercase
23      text_new_path = run_wcd.convert_file_to_lowercase(text_path)
24
25      for i in range(repeat):
26        call(['./wcd', dictionary_new_path, text_new_path], stderr=mes_f)
27      run_wcd.delete_temporary_file(text_new_path)
28
29    run_wcd.delete_temporary_file(dictionary_new_path)
30
31def analyze_rslt():     
32      mes_f = open('mesfile', 'r')
33      results = mes_f.read().split(' ')
34      results_int = []
35      rows = {}
36      for r in results[:-1]:
37        results_int.append(int(r))
38      first_row = '\t'
39      for testfile in testfiles:
40        first_row += testfile + '  &\t'
41      first_row =  first_row[:-4]
42      print first_row
43      for dictionary in dictionaryfiles:
44        row = dictionary + '   \t&\t'
45        for testfile in testfiles:
46          result = results_int[0:repeat]
47          results_int = results_int[repeat:]
48          row +=  str(min(result)/1000.0) + '   &\t'
49        row = row[:-4]
50        row +='\\\\ \\hline'
51        print row
52       
53if __name__ == "__main__":
54  run_test()
55  analyze_rslt()
56 
57
58           
59       
60       
61       
62       
63       
64       
65       
66       
67       
68       
69       
70       
71       
72       
Note: See TracBrowser for help on using the repository browser.