当前位置: 首页>>代码示例>>Python>>正文


Python Scanner.cmd_manual方法代码示例

本文整理汇总了Python中scanner.Scanner.cmd_manual方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.cmd_manual方法的具体用法?Python Scanner.cmd_manual怎么用?Python Scanner.cmd_manual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scanner.Scanner的用法示例。


在下文中一共展示了Scanner.cmd_manual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AthBenchmark

# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import cmd_manual [as 别名]
class AthBenchmark(object):

    def __init__(self, iface):
        self.scanner = Scanner(iface)
        fn = '%s/spectral_scan0' % self.scanner.get_debugfs_dir()
        self.file_reader = SpectrumFileReader(fn)
        self.interface = iface

    def get_samples(self, duration):
        sps = 0
        end = datetime.now() + timedelta(seconds=duration)
        while datetime.now() < end:
            try:
                ts, samples = self.file_reader.sample_queue.get(timeout=0.1)
            except Queue.Empty:
                continue
            sps += len(samples) / (17 + 56)  # (header + payload in HT20)
        print "total: %d sps" % sps
        sps /= float(duration)
        return sps

    # count samples in chanscan
    def benchmark_chanscan(self, duration=5, samplecount=8):
        print "\nrun benchmark chanscan with samplecount=%d, duration=%d " % (samplecount, duration)
        self.scanner.cmd_set_samplecount(samplecount)
        self.scanner.mode_chanscan()
        self.scanner.start()
        sps = self.get_samples(duration=duration)
        self.scanner.stop()
        self.file_reader.flush()
        print "%.2f sps, chanscan" % sps
        return sps

    # count samples in bg mode (w/o) load
    def benchmark_background(self, duration=5):
        print "\nrun benchmark background with duration=%d " % duration
        self.scanner.mode_noninvasive_background()
        self.scanner.dev_add_monitor()
        self.scanner.start()
        sps = self.get_samples(duration=duration)
        self.scanner.stop()
        self.file_reader.flush()
        print "%.2f sps, background scan " % sps
        return sps

    def benchmark_manual(self, samplecount=127):
        print "\nrun benchmark manual with samplecount=%d " % samplecount
        self.scanner.mode_manual()
        self.scanner.cmd_manual()
        self.scanner.cmd_set_samplecount(samplecount)
        self.scanner.dev_add_monitor()
        self.scanner.cmd_trigger()
        sps = 0
        reread = 3
        while reread:
            try:
                ts, samples = self.file_reader.sample_queue.get(timeout=0.1)
                sps += len(samples) / (17 + 56)  # (header + payload in HT20)
            except Queue.Empty:
                pass
            reread -= 1
        self.scanner.stop()
        self.file_reader.flush()
        print "got %d samples in manual mode" % sps
        return sps

    def main(self):
        samplecount = [1, 10, 50, 100, 150, 200, 255]
        for sc in samplecount:
            sps = self.benchmark_chanscan( duration=5, samplecount=sc)
            print "sps / samplecount: %.2f" % (sps / sc)
            time.sleep(0.2)

        self.benchmark_background(duration=5)
        time.sleep(0.2)

        self.benchmark_manual(samplecount=127)
        time.sleep(0.2)

        self.cleanup()

    def cleanup(self):
        # self.scanner.stop()
        self.file_reader.stop()
开发者ID:bcopeland,项目名称:speccy,代码行数:86,代码来源:benchmark.py


注:本文中的scanner.Scanner.cmd_manual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。