mtk 天玑型号对应关系

MT6883(天玑1000C)
MT6885(天玑1000L)
MT6875(天玑820)=5G-A+T
MT6873(天玑800)=5G-A
MT6853T(天玑800U)=5G-B+
MT6853(天玑720) = 5G-B
MT6833(天玑700)= 5G-C
MT6893(天玑1200)
MT6891(天玑1100) 平板迅鲲1300T
MT6877(天玑900)
MT6833P(天机810)
MT6983(天玑9000)

def main(argv): # print("argv="), # print(argv) #print(type(argv)) VersionNum = "V6.0" if type(argv) == type("str"): argv = argv.split(' ') argv_str = "" for ar in argv: argv_str += str(ar) + " " # print(argv_str) logging.basicConfig(level=logging.INFO, format='%(asctime)s.%(msecs)03d %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') begin = datetime.datetime.now() usage = "Usage: analysismain.py systracefile [options]" parser = optparse.OptionParser(usage) parser.add_option("-d", "--device", type="int", dest="devicetype", help="8250:msm8250, 8350:msm8350, 8450:msm8450, 8650:msm8650, 6115:msm6115, 8635:msm8635" "6225:msm6225, 62252:msm6225pro, 6375:msm6375, 7325:msm7325, 7435:msm7435, 6450:msm6450," "7475:msm7475, 8475:msm8475, 84752:msm8475_lowfreq, 8550:msm8550, 7675:msm7675, 7635:msm7635," "6895:MT6895, 6877:MT6877, 6878:MT6878, 6853:MT6853, 6835:MT6835,68352:MT6835_24E," "6833:MT6833, 6769:MT6769, 6789:MT6789, 6886:MT6886" "6781:MT6781, 6785:MT6785, 6893:MT6893," "6891:MT6891,") parser.add_option("-t", "--threadpid", type="int", dest="watchingTid", help="watching thread tid") parser.add_option("-s", "--starttime", type="float", dest="starttime", help="start time(ms)") parser.add_option("-e", "--endtime", type="float", dest="endtime", help="end time(ms)") parser.add_option("-l", "--timeDuration", type="float", dest="time", help="duration(ms)") parser.add_option("-a", "--launching", type="int", dest="launching", help="1:launching time as starttime and endtime, " "2:launching time as starttime and endtime and launching app as watching thread") parser.add_option("-v", "--view", type="int", dest="view", help="1:uithread as watching thread," "2:renderthread as watchingtid," "3:surfaceflinger as watchingtid") parser.add_option("-g", "--tag", type="string", dest="tag", help="support tag") parser.add_option("-m", "--maxminfreq", type="int", dest="maxminfreq", help="systrace init freq, 1:maxfreq,2:minfreq") parser.add_option("-f", "--freqbounds", action="store_true", dest="freqbounds", help="the time when all cpu has cpufreq info as starttime") parser.add_option("-w", "--wakingEnable", action="store_true", dest="wakingEnable", help="use sched_waking to compute thread dependency") parser.add_option("-r", "--replaceTitle", action="store_true", dest="replaceTitle", help="replace systrace html title") parser.add_option("-k", "--threadload", type="string", dest="loadserialtid", help="thread load serial") parser.add_option("-i", "--runnableSerial", action="store_true", dest="runnableSerial", help="runnable Serial") parser.add_option("-q", "--irqload", action="store_true", dest="irqload", help="irq load") parser.add_option("-z", "--allThreadSlice", type="int", dest="allThreadSlice", help="all thread slice") parser.add_option("-p", "--frameTest", action="store_true", dest="frameTest", help="frame test") parser.add_option("-c", "--croppedVersion", action="store_true", dest="croppedVersion", help="Cropped version") parser.add_option("-n", "--runqEnable", action="store_true", dest="runqEnable", help="runqEnable") parser.add_option("-b", "--blockEnable", type="int", dest="blockEnable", help="blockEnable") parser.add_option("-u", "--mem", type="int", dest="memEnable", help="memEnable") parser.add_option("-j", "--inode_file", type="string", dest="inode_file", help="inode_file") parser.add_option("-x", "--power_info_get", type="int", dest="power_info_get", help="power_info_get") parser.add_option("-y", "--schedEnable", action="store_true", dest="schedEnable", help="schedEnable") parser.add_option("-o", "--onlycompate", action="store_true", dest="onlycompate", help="onlycompate") logging.info(VersionNum) options, args = parser.parse_args(argv[1:]) if options.starttime != None and options.time != None: options.endtime = options.starttime + options.time if options.endtime != None and options.time != None and options.starttime == None: options.starttime = options.endtime - options.time logging.info(options) if args.__len__() != 1: logging.info("param error!") sys.exit() device = 0 if options.devicetype == 8450: device = "msm8450" elif options.devicetype == 8250: device = "msm8250" elif options.devicetype == 8350: device = "msm8350" elif options.devicetype == 8550: device = "msm8550" elif options.devicetype == 8650: device = "msm8650" elif options.devicetype == 8635: device = "msm8635" elif options.devicetype == 7635: device = "msm7635" elif options.devicetype == 7675: device = "msm7675" elif options.devicetype == 7325: device = "msm7325" elif options.devicetype == 7435: device = "msm7435" elif options.devicetype == 6450: device = "msm6450" elif options.devicetype == 6115: device = "msm6115" elif options.devicetype == 6225: device = "msm6225" elif options.devicetype == 62252: device = "msm6225pro" elif options.devicetype == 6375: device = "msm6375" elif options.devicetype == 7475: device = "msm7475" elif options.devicetype == 8475: device = "msm8475" elif options.devicetype == 84752: device = "msm8475_lowfreq" elif options.devicetype == 6891: device = "MT6891" elif options.devicetype == 6893: device = "MT6893" elif options.devicetype == 6895: device = "MT6895" elif options.devicetype == 6769: device = "MT6769" elif options.devicetype == 6781: device = "MT6781" elif options.devicetype == 6785: device = "MT6785" elif options.devicetype == 6789: device = "MT6789" elif options.devicetype == 6833: device = "MT6833" elif options.devicetype == 6835: device = "MT6835" elif options.devicetype == 68352: device = "MT68352" elif options.devicetype == 6853: device = "MT6853" elif options.devicetype == 6877: device = "MT6877" elif options.devicetype == 6878: device = "MT6878" elif options.devicetype == 6886: device = "MT6886" elif options.devicetype == 9863: device = "SC9863" elif options.devicetype == 612: device = "SC612" else: if options.power_info_get == None: raise Exception("Device type is None!") if options.endtime != None and options.starttime != None and options.starttime >= options.endtime: raise Exception("Input param error, endtime need be bigger than starttime!") logging.info("is dir"), logging.info(os.path.isdir(args[0])) path = args[0] if os.path.isdir(path) == False: controller = Controller(args[0], device, options, argv_str) if controller.get_power_into_ret == True: return None ret = controller.run() end = datetime.datetime.now() logging.info("Elapsed Time=" + str(end - begin)) if ret == "perfetto_replace" and options.replaceTitle != True: if options.endtime != None and options.starttime != None and options.starttime >= options.endtime: raise Exception("Input param error, endtime need be bigger than starttime!") logging.info("new_test:"), logging.info(controller.updatetsfile) controller = Controller(controller.updatetsfile, device, options, argv_str) ret = controller.run() end = datetime.datetime.now() logging.info("Elapsed Time=" +str(end - begin)) if ret != None: logging.info("Test result in " +str(ret)) elif ret != None: logging.info("Test result in " + str(ret)) else: logging.info("ret = " + str(ret)) return ret else: if options.onlycompate != True: for dirpath, dirnames, filenames in os.walk(path): for filepath in filenames: ret = None #print (os.path.join(dirpath, filepath)) filepath_full = os.path.join(dirpath, filepath) if filepath_full.endswith(".html") or filepath_full.endswith(".perfetto-trace") or filepath_full.endswith(".perfetto"): logging.info(filepath_full) controller = Controller(filepath_full, device, options, argv_str) ret = controller.run() end = datetime.datetime.now() logging.info("Elapsed Time=" + str(end - begin)) if ret == "perfetto_replace" and options.replaceTitle != True: if options.endtime != None and options.starttime != None and options.starttime >= options.endtime: raise Exception("Input param error, endtime need be bigger than starttime!") logging.info("new_test:"), logging.info(controller.updatetsfile) controller = Controller(controller.updatetsfile, device, options, argv_str) ret = controller.run() end = datetime.datetime.now() logging.info("Elapsed Time=" +str(end - begin)) if ret != None: if options.croppedVersion != True: logging.info("Test result in " + str(ret)) elif ret != None: if options.croppedVersion != True: logging.info("Test result in " + str(ret)) else: logging.info("ret =" + str(ret)) #if os.path.isdir(path_out) == False: # os.mkdir(path_out) #if ret != None: # des = ret.replace(path, path + "_rtrace_out", 1) # logging.info("move from %s, to %s" %(ret, des)) # shutil.copy(ret, des) if path != None: compare(path) 逐行解析
最新发布
12-02
这段代码是一个 Python 脚本的 `main` 函数,用于解析命令行参数并控制一个性能分析工具(如 Systrace)的执行流程。它使用了 `optparse` 解析参数、`logging` 记录日志、`os` 操作文件系统,并调用了一个名为 `Controller` 的类来处理具体的分析任务。 --- ### 📌 逐行解析 #### 1. 函数定义 ```python def main(argv): ``` - 定义 `main` 函数,接收命令行参数 `argv`(通常来自 `sys.argv`)。 #### 2. 版本号设置 ```python VersionNum = "V6.0" ``` - 设置脚本版本号为 `V6.0`。 #### 3. 参数类型判断与处理 ```python if type(argv) == type("str"): argv = argv.split(' ') ``` - 如果 `argv` 是字符串,则将其按空格分割为列表,模拟命令行参数格式。 #### 4. 构建参数字符串 ```python argv_str = "" for ar in argv: argv_str += str(ar) + " " ``` - 构建完整的命令行参数字符串,用于后续日志记录或传递。 #### 5. 日志配置 ```python logging.basicConfig(level=logging.INFO, format='%(asctime)s.%(msecs)03d %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') ``` - 配置日志输出格式和级别。 #### 6. 记录开始时间 ```python begin = datetime.datetime.now() ``` - 记录脚本开始执行的时间,用于统计耗时。 #### 7. 定义命令行用法 ```python usage = "Usage: analysismain.py systracefile [options]" ``` - 设置脚本的使用说明。 #### 8. 创建命令行解析器 ```python parser = optparse.OptionParser(usage) ``` - 使用 `optparse` 模块创建一个命令行参数解析器。 #### 9. 添加各种命令行选项(共 30+ 个) ```python parser.add_option("-d", "--device", type="int", dest="devicetype", help="8250:msm8250, 8350:msm8350, ...") ... ``` - 添加多个命令行选项,支持设备类型、线程 ID、时间范围、显示模式、内存分析等高级功能。 - 每个选项都有对应的 `dest`(变量名)和 `help`(帮助信息)。 #### 10. 输出版本号 ```python logging.info(VersionNum) ``` - 打印当前脚本版本信息。 #### 11. 解析命令行参数 ```python options, args = parser.parse_args(argv[1:]) ``` - 使用 `optparse` 解析命令行参数,得到 `options`(选项参数)和 `args`(位置参数)。 #### 12. 时间范围逻辑处理 ```python if options.starttime != None and options.time != None: options.endtime = options.starttime + options.time if options.endtime != None and options.time != None and options.starttime == None: options.starttime = options.endtime - options.time ``` - 如果提供了 `starttime` 和 `time`,自动计算 `endtime`。 - 如果提供了 `endtime` 和 `time`,自动计算 `starttime`。 #### 13. 参数校验 ```python if args.__len__() != 1: logging.info("param error!") sys.exit() ``` - 确保只有一个位置参数(即输入文件路径),否则报错退出。 #### 14. 设备类型映射 ```python if options.devicetype == 8450: device = "msm8450" ... ``` - 根据传入的设备编号映射为具体的设备名称字符串。 #### 15. 时间范围合法性检查 ```python if options.endtime != None and options.starttime != None and options.starttime >= options.endtime: raise Exception("Input param error, endtime need be bigger than starttime!") ``` - 如果结束时间小于等于开始时间,抛出异常。 #### 16. 判断输入路径是否为目录 ```python path = args[0] if os.path.isdir(path) == False: ``` - 如果不是目录,处理单个文件;否则递归处理目录下所有文件。 #### 17. 实例化 Controller 并运行分析 ```python controller = Controller(args[0], device, options, argv_str) ret = controller.run() ``` - 创建 `Controller` 实例,调用 `run()` 方法执行分析任务。 #### 18. 如果返回值为特定字符串,重新运行 ```python if ret == "perfetto_replace" and options.replaceTitle != True: ... controller = Controller(controller.updatetsfile, device, options, argv_str) ret = controller.run() ``` - 如果返回值为 `"perfetto_replace"`,并且未设置 `replaceTitle`,则使用更新后的文件路径重新运行。 #### 19. 打印结果或耗时 ```python logging.info("Test result in " + str(ret)) logging.info("Elapsed Time=" + str(end - begin)) ``` - 输出分析结果路径和总耗时。 #### 20. 如果输入是目录,遍历处理所有文件 ```python else: for dirpath, dirnames, filenames in os.walk(path): for filepath in filenames: ... controller = Controller(filepath_full, device, options, argv_str) ret = controller.run() ``` - 使用 `os.walk` 遍历目录,处理所有 `.html`、`.perfetto-trace`、`.perfetto` 文件。 #### 21. 最后调用 compare 函数(可能用于对比结果) ```python compare(path) ``` - 调用 `compare()` 函数进行结果对比(未在代码中定义)。 --- ### ✅ 总结 这段代码主要完成了以下功能: | 功能模块 | 说明 | |----------|------| | **命令行参数解析** | 使用 `optparse` 解析各种参数,包括设备类型、线程 ID、时间范围等。 | | **日志记录** | 使用 `logging` 模块记录执行过程和调试信息。 | | **时间处理** | 自动计算时间范围,确保 `starttime < endtime`。 | | **设备映射** | 将设备编号映射为具体的设备名称。 | | **文件处理** | 支持单个文件或整个目录的处理,递归处理 `.html` 和 `.perfetto` 文件。 | | **分析执行** | 调用 `Controller` 类进行分析,支持多次运行以处理特定返回结果。 | | **结果输出** | 输出分析结果路径和耗时,支持结果对比。 | ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海蓝光科技

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值