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


Python Stats.print_stats方法代码示例

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


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

示例1: main

# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import print_stats [as 别名]
def main(args):
    states = read_states(args.input)

    stats = Stats(sys.argv)
    cipher = Spritz()

    settings = Settings(args)

    prompt_step = max(1, len(states) // 20)
    i = 0
    for initial_state, revealed_state, prefix_length in states:
        if args.verbosity > 1 and i % prompt_step == 0:
            print('test #:', i)
        i += 1

        KNOWN_KEYSTREAM_SIZE = 3 * initial_state.size
        cipher.initialize_state(initial_state.state)
        known_keystream = cipher.keystream(prefix_length + KNOWN_KEYSTREAM_SIZE)
        settings.prefix_length = prefix_length

        # in case we want to skip less keystream than revealed_state is
        # generate in, we cut off beginning of keystream and move 
        # initial_state apropriatelly
        if args.input and args.force_prefix_length and args.force_prefix_length < prefix_length:
            new_prefix_length = args.force_prefix_length
            new_start_offset = prefix_length - new_prefix_length
            settings.prefix_length = new_prefix_length
            known_keystream = known_keystream[new_start_offset:]   
            cipher.initialize_state(initial_state.state)
            cipher.keystream(new_start_offset)
            initial_state = SpritzState(cipher.state)

        cipher.initialize_state(initial_state.state)
        cipher.keystream(prefix_length)
        found_state, round_stats = backtrack.kpa(
            known_keystream,
            revealed_state,
            settings,
        )

        if found_state and initial_state != found_state:
            print('incorrect result, this should not happen')
            assert False

        stats.add(round_stats)

    stats.print_stats(args.verbosity)
    # dump pickled stats object
    if not args.no_stats_log:
        timestamp = datetime.datetime.today().strftime('%y%m%d_%H%M%S_%f')
        os.makedirs('stats/', exist_ok=True)
        with open('stats/' + timestamp, 'wb') as f:
            pickle.dump(stats, f)
开发者ID:mgabris,项目名称:state-recovery-backtrack,代码行数:55,代码来源:benchmark.py


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