TestGeneratorTablePerformance.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:urh 作者: jopohl 项目源码 文件源码
def test_performance(self):
        self.cframe = self.form.compare_frame_controller
        self.gframe = self.form.generator_tab_controller
        self.form.ui.tabWidget.setCurrentIndex(2)
        self.cframe.ui.cbProtoView.setCurrentIndex(0)
        self.gframe.ui.cbViewType.setCurrentIndex(0)
        proto = self.__build_protocol()
        self.cframe.add_protocol(proto)
        proto.qt_signals.protocol_updated.emit()
        self.assertEqual(self.cframe.protocol_model.row_count, self.NUM_MESSAGES)
        self.assertEqual(self.cframe.protocol_model.col_count, self.BITS_PER_MESSAGE)
        self.__add_labels()
        item = self.gframe.tree_model.rootItem.children[0].children[0]
        index = self.gframe.tree_model.createIndex(0, 0, item)
        rect = self.gframe.ui.treeProtocols.visualRect(index)
        QTest.mousePress(self.gframe.ui.treeProtocols.viewport(), Qt.LeftButton, pos = rect.center())

        self.assertEqual(self.gframe.ui.treeProtocols.selectedIndexes()[0], index)
        mimedata = self.gframe.tree_model.mimeData(self.gframe.ui.treeProtocols.selectedIndexes())
        t  = time.time()
        self.gframe.table_model.dropMimeData(mimedata, 1, -1, -1, self.gframe.table_model.createIndex(0, 0))
        print("{0}: {1} s".format("Time for dropping mimedata", (time.time() - t)))
        self.assertEqual(self.gframe.table_model.row_count, self.NUM_MESSAGES)

        print("==============================00")
        indx = self.gframe.table_model.createIndex(int(self.NUM_MESSAGES / 2), int(self.BITS_PER_MESSAGE / 2))
        roles = (Qt.DisplayRole, Qt.BackgroundColorRole, Qt.TextAlignmentRole, Qt.TextColorRole, Qt.FontRole)
        time_for_display = 100
        for role in roles:
            t = time.time()
            self.gframe.table_model.data(indx, role = role)
            microseconds = (time.time() - t) * 10 ** 6
            self.assertLessEqual(microseconds, 2 * time_for_display, msg=self.__role_to_str(role))
            if role == Qt.DisplayRole:
                time_for_display = microseconds
            print("{0}: {1} µs".format(self.__role_to_str(role), microseconds))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号