statistics.py (be43a2c5f85946a5f264cd59b5a3944b88076939) | statistics.py (c6d439803a044ea209139672b25e35fe8d7f4aa0) |
---|---|
1#*************************************************************************************** 2# Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3# 4# XiangShan is licensed under Mulan PSL v2. 5# You can use this software according to the terms and conditions of the Mulan PSL v2. 6# You may obtain a copy of Mulan PSL v2 at: 7# http://license.coscl.org.cn/MulanPSL2 8# 9# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12# 13# See the Mulan PSL v2 for more details. 14#*************************************************************************************** 15 |
|
1import os 2import argparse 3 4def printMap(mp): 5 len_key = max(map(lambda s: len(s), mp.keys())) 6 len_value = max(map(lambda v: len(str(v)), mp.values())) 7 pattern = "{:<" +str(len_key) + "} {:<" +str(len_value)+ "} {:<7}%" 8 total = sum(mp.values()) --- 14 unchanged lines hidden (view full) --- 23 if last!="" : 24 mymap[last] = cnt 25 last = line[7:-2] 26 cnt = 1 27 else: 28 cnt = cnt + 1 29 line = f.readline() 30 mymap[last] = cnt | 16import os 17import argparse 18 19def printMap(mp): 20 len_key = max(map(lambda s: len(s), mp.keys())) 21 len_value = max(map(lambda v: len(str(v)), mp.values())) 22 pattern = "{:<" +str(len_key) + "} {:<" +str(len_value)+ "} {:<7}%" 23 total = sum(mp.values()) --- 14 unchanged lines hidden (view full) --- 38 if last!="" : 39 mymap[last] = cnt 40 last = line[7:-2] 41 cnt = 1 42 else: 43 cnt = cnt + 1 44 line = f.readline() 45 mymap[last] = cnt |
31 printMap(mymap) | 46 printMap(mymap) |
32 33logLevels = ['ALL', 'DEBUG', 'INFO', 'WARN', 'ERROR'] 34 35def listToStr(lst): 36 acc = '' 37 for l in lst: 38 acc += '|' + str(l) if acc else str(l) 39 return acc --- 19 unchanged lines hidden (view full) --- 59 mymap[m] = getNumLogLines(filename, [m]) 60 printMap(mymap) 61 62def main(): 63 parser = argparse.ArgumentParser() 64 parser.add_argument("-v", "--verilogFile", help="verilog file path", type=str) 65 parser.add_argument("-l", "--logFile", help="log file path", type=str) 66 args = parser.parse_args() | 47 48logLevels = ['ALL', 'DEBUG', 'INFO', 'WARN', 'ERROR'] 49 50def listToStr(lst): 51 acc = '' 52 for l in lst: 53 acc += '|' + str(l) if acc else str(l) 54 return acc --- 19 unchanged lines hidden (view full) --- 74 mymap[m] = getNumLogLines(filename, [m]) 75 printMap(mymap) 76 77def main(): 78 parser = argparse.ArgumentParser() 79 parser.add_argument("-v", "--verilogFile", help="verilog file path", type=str) 80 parser.add_argument("-l", "--logFile", help="log file path", type=str) 81 args = parser.parse_args() |
67 | 82 |
68 if args.verilogFile: 69 analyzeVerilog(args.verilogFile) | 83 if args.verilogFile: 84 analyzeVerilog(args.verilogFile) |
70 | 85 |
71 if args.logFile: 72 analyzeLog(args.logFile) | 86 if args.logFile: 87 analyzeLog(args.logFile) |
73 | 88 |
74 if not args.verilogFile and not args.logFile: 75 parser.print_help() 76 77if __name__ == '__main__': 78 main() 79 | 89 if not args.verilogFile and not args.logFile: 90 parser.print_help() 91 92if __name__ == '__main__': 93 main() 94 |