def get_memory_data(package_name, pic_name='memory'):
        i = 0
        last_page_name = ''
        last_memory_data = 0
        memory_increase = 0
        while i < config.collect_data_count:
            LogUtil.log_i('Inspect memory')
            memory_data = int(AndroidUtil.get_memory_data(package_name))  # 当前采集到的数据
            now_page_name = AndroidUtil.get_cur_activity()
            # 目前暂时粗略的计算增量,当页面不一样时,计算增量
            if now_page_name != last_page_name:
                memory_increase = memory_data - last_memory_data
                if memory_increase < 0:
                    # 对于发生GC的情况,内存增量可能是负值, 暂时先不做处理
                    pass
                PerformanceControl.memory_datas.append([now_page_name, last_page_name, memory_increase])
                last_page_name = now_page_name
            else:
                last_memory_data = memory_data
                i += 1
                continue
            # 内存增量大于某个值就认为是有问题
            if memory_increase >= 10 * 1024:
                AdbUtil.screenshot(pic_name)
                LogUtil.log_i('Inspect memory 12')
            LogUtil.log_i('Inspect memory 13')

            # 设定多久采集一次数据
            time.sleep(config.collect_data_interval)
            i += 1
        def handle_error_data(frame_count, jank_count, fps, current_page):
            # 暂时当fps < 50 或者 jank_count > 10 我们认为是不达标的
            if fps < 50 or jank_count > 10:
                # 截图
                AdbUtil.screenshot(self.pic_name)
                # 保存日志

                GetFpsDataThread.fps_error_datas.append([
                    frame_count, jank_count, fps, current_page, self.pic_name
                ])
    def get_cpu_data_silent(package_name, pic_name='cpu'):
        i = 0
        while i < config.collect_data_count:
            LogUtil.log_i('Inspect cpu')
            current_page, cpu_data = AndroidUtil.get_cpu_data(package_name)  # 当前采集到的数据
            if cpu_data >= 50.00:

                AdbUtil.screenshot(pic_name)
            else:
                pass
            PerformanceControl.cpu_datas.append([current_page, cpu_data])
            time.sleep(config.collect_data_interval)  # 设定多久采集一次数据
            i += 1
        LogUtil.log_i('Inspect cpu finish')
 def run(self):
     exec_count = 0
     while True:
         LogUtil.log_i('Inspect cpu')
         if exec_count > config.collect_data_count:
             break
         current_page, cpu_datas = AndroidUtil.get_cpu_data(self.package_name)#当前采集到的数据
         if cpu_datas >= 50.00:
             # 对错误进行处理
             AdbUtil.screenshot(self.pic_name)
         else:
             pass
         GetCpuDataThread.cpu_datas.append([current_page, cpu_datas])
         # 设定多久采集一次数据
         time.sleep(config.collect_data_interval)
         exec_count += 1
     LogUtil.log_i('Inspect cpu finish')
Example #5
0
 def run(self):
     i = 0
     pkgName = config.test_package_name
     while i < config.collect_data_count:
         LogUtil.log_i('Inspect cpu')
         cpudata = AndroidUtil.get_cpu_data(pkgName)  #当前采集到的数据
         if cpudata >= 50.00:
             cpuerror = cpudata
             self.CPUerror.append(cpuerror)
             AdbUtil.screenshot()
         else:
             pass
         self.CPUdata.append(cpudata)
         time.sleep(config.collect_data_interval)  #设定多久采集一次数据
         i += 1
     print "CPUerror:", self.CPUerror, "CPUdata:", self.CPUdata
     GetCpuDataThread.task_finish = True
     LogUtil.log_i('Inspect cpu finish')
Example #6
0
    def run(self):
        i = 0
        pkgName = config.test_package_name
        while i < config.collect_data_count:
            LogUtil.log_i('Inspect memory')
            memorydata = int(AndroidUtil.get_memory_data(pkgName))  #当前采集到的数据
            if memorydata >= 50 * 1024:
                memoryerror = memorydata
                self.Memoryerror.append(memoryerror)
                AdbUtil.screenshot()
                LogUtil.log_i('Inspect memory 12')
            LogUtil.log_i('Inspect memory 13')
            self.Memorydata.append(memorydata)
            # time.sleep(self.interval)#设定多久采集一次数据
            i += 1

        GetMemoryDataThread.task_finish = True
        print self.Memoryerror, self.Memorydata
Example #7
0
def get_silent_cpu_data(pic_name='silent_cpu'):
    exec_count = 0
    while True:
        if exec_count > config.collect_data_count:
            __pre_silent_cpu_data()
            __publish_silent_cpu_data()
            break
        # if config.run_finish or config.run_silent_state == config.SlientState.FINISH:
        #     break
        LogUtil.log_i('silent Inspect cpu')
        current_page, cpu_data = AndroidUtil.get_cpu_data(
            package_name)  # 当前采集到的数据
        if cpu_data >= 50.00:

            AdbUtil.screenshot(pic_name)
        else:
            pass
        cpu_datas_silent.append([current_page, cpu_data])
        time.sleep(config.collect_data_interval)  # 设定多久采集一次数据
        exec_count += 1
    LogUtil.log_i('silent Inspect cpu finish')
Example #8
0
def get_memory_data(pic_name='memory'):
    exec_count = 0
    while True:
        if exec_count > config.collect_data_count:
            __pre_memory_data()
            __publish_memory_data()
            break
        # if config.run_finish:
        #     break

        LogUtil.log_i('Inspect memory' + str(exec_count))
        memory_data = int(
            AndroidUtil.get_memory_data(package_name))  # 当前采集到的数据
        now_page_name = AndroidUtil.get_cur_activity()
        memory_datas.append([now_page_name, memory_data])
        # 内存增量大于某个值就认为是有问题
        if memory_data >= 10 * 1024:
            AdbUtil.screenshot(pic_name)

        # 设定多久采集一次数据
        time.sleep(config.collect_data_interval)
        exec_count += 1
Example #9
0
    def run(self):
        exec_count = 0
        last_page_name = ''
        last_memory_data = 0
        try:
            while True:
                LogUtil.log_i('Inspect memory')
                if exec_count > config.collect_data_count:
                    break
                memory_data = int(
                    AndroidUtil.get_memory_data(self.package_name))  #当前采集到的数据
                now_page_name = AndroidUtil.get_cur_activity()
                # 目前暂时粗略的计算增量,当页面不一样时,计算增量
                if now_page_name != last_page_name:
                    memory_increase = memory_data - last_memory_data
                    if memory_increase < 0:
                        # 对于发生GC的情况,内存增量可能是负值, 暂时先不做处理
                        pass
                    GetMemoryDataThread.memory_datas.append(
                        [now_page_name, last_page_name, memory_increase])
                    last_page_name = now_page_name
                else:
                    last_memory_data = memory_data
                    exec_count += 1
                    continue

                # 内存增量大于某个值就认为是有问题
                if memory_increase >= 10 * 1024:
                    AdbUtil.screenshot(self.pic_name)
                    LogUtil.log_i('Inspect memory 12')
                LogUtil.log_i('Inspect memory 13')

                # 设定多久采集一次数据
                time.sleep(config.collect_data_interval)
                exec_count += 1
        except Exception as e:
            LogUtil.log_e('get cpu error' + e.message)
Example #10
0
 def handle_error_data(current_flow):
     if current_flow > 1 * 1024:
         current_page = AndroidUtil.get_cur_activity()
         AdbUtil.screenshot(self.pic_name)
         GetFlowDataThread.flow_error_datas.append(
             [current_flow, current_page, self.pic_name])
 def handle_error_data(current_flow):
     if current_flow > 5 * 1024:
         # 异常处理
         AdbUtil.screenshot(pic_name)
 def handle_error_data(cost_time):
     if cost_time != '' and cost_time is not None:
         cost_time_value = handle_cost_time(cost_time)
         if cost_time_value > 3000:
             AdbUtil.screenshot(pic_name)
 def handle_error_data(jank_count, fps):
     # 暂时当fps < 50 或者 jank_count > 10 我们认为是不达标的
     if fps < 50 or jank_count > 10:
         # 截图
         AdbUtil.screenshot(pic_name)
 def handle_error_data(current_flow):
     if current_flow > 1 * 1024:
         AdbUtil.screenshot(self.pic_name)
Example #15
0
 def handle_error_data():
     if self.cost_time != '' and self.cost_time is not None:
         cost_time_value = handle_cost_time(self.cost_time)
         if cost_time_value > 3000:
             AdbUtil.screenshot(self.pic_name)
             GetKpiDataThread.kpi_error_datas.append([self.now_page_name, self.jump_page, self.cost_time, self.pic_name])
 def handle_error_data():
     if self.cost_time != '' and self.cost_time is not None:
         cost_time_value = handle_cost_time(self.cost_time)
         if cost_time_value > 3000:
             AdbUtil.screenshot(self.pic_name)