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


Python Profile.stats方法代码示例

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


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

示例1: build_profile

# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import stats [as 别名]
def build_profile(host, path):
    print("Profiling {0} with Host: {1}, Path: {2}".format(collection, host, path))
    bm_id = "H{0}P{1}".format(host, path)
    profile_id = "{0}-{1}".format(col_id, bm_id)
    profiling_start = time.time()
    p = Profile(name="{0}Hosts {1} Paths {2}".format(collection, host, path),
                description="{0} collection profile with maximum {1} host and {2} path secgment(s).".format(collection, host, path),
                homepage="http://www.webarchive.org.uk/ukwa/",
                accesspoint="http://www.webarchive.org.uk/wayback/",
                memento_compliance="https://oduwsdl.github.io/terms/mementosupport#native",
                timegate="http://www.webarchive.org.uk/wayback/archive/",
                timemap="http://www.webarchive.org.uk/wayback/archive/timemap/link/",
                established="2004",
                profile_updated=time.strftime("%Y-%m-%dT%H:%M:%SZ"),
                mechanism="https://oduwsdl.github.io/terms/mechanism#cdx")
    cp = CDXProfiler(max_host_segments=host,
                     max_path_segments=path,
                     global_stats=True)
    cp.process_cdxes(sys.argv[1:])
    cdx_processing_done = time.time()
    cp.calculate_stats()
    stats_calculation_done = time.time()
    p.stats = cp.stats
    jsonstr = p.to_json()
    opf = "profile-{0}.json".format(profile_id)
    opfpath = os.path.join(bmdir, opf)
    write_json(jsonstr, filepath=opfpath, compress=True)
    profiling_done = time.time()
    bm = {
        "profile": opf,
        "collection": col_id,
        "max_host": host,
        "max_path": path,
        "cdx_size": cdx_size,
        "cdx_lines_total": cp.total_lines,
        "cdx_lines_skipped": cp.skipped_lines,
        "profile_size": os.path.getsize(opfpath),
        "profile_size_compressed": os.path.getsize(opfpath + ".gz"),
        "urir_count": p.stats["urir"],
        "urim_count": p.stats["urim"]["total"],
        "suburi_keys": len(p.stats["suburi"]),
        "time_keys": len(p.stats["time"]),
        "mediatype_keys": len(p.stats["mediatype"]),
        "language_keys": len(p.stats["language"]),
        "cdx_processing_time": cdx_processing_done - profiling_start,
        "stats_calculation_time": stats_calculation_done - cdx_processing_done,
        "profiling_time": profiling_done - profiling_start
    }
    all_bms["bms"][bm_id] = bm
    jsonstr = json.dumps(bm, sort_keys=True, indent=4, separators=(",", ": "))
    opf = "bm-{0}.json".format(profile_id)
    opfpath = os.path.join(bmdir, opf)
    write_json(jsonstr, filepath=opfpath)
开发者ID:oduwsdl,项目名称:archive_profiler,代码行数:55,代码来源:profiling_benchmarker.py

示例2: Profile

# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import stats [as 别名]
        sys.exit(0)
    scriptdir = os.path.dirname(os.path.abspath(__file__))
    config = ConfigParser.ConfigParser()
    config.read(os.path.join(scriptdir, "config.ini"))
    p = Profile(name=config.get("archive", "name"),
                description=config.get("archive", "description"),
                homepage=config.get("archive", "homepage"),
                accesspoint=config.get("archive", "accesspoint"),
                memento_compliance=config.get("archive", "memento_compliance"),
                timegate=config.get("archive", "timegate"),
                timemap=config.get("archive", "timemap"),
                established=config.get("archive", "established"),
                profile_updated=time.strftime("%Y-%m-%dT%H:%M:%SZ"),
                mechanism="https://oduwsdl.github.io/terms/mechanism#cdx")
    cp = CDXExtractProfiler(max_host_segments=config.get("profile", "max_host_segments"),
                            max_path_segments=config.get("profile", "max_path_segments"),
                            global_stats=config.getboolean("profile", "generate_global_stats"))
    cp.process_cdx_extracts(sys.argv[1:])
    cp.calculate_stats()
    p.stats = cp.stats
    if config.getboolean("profile", "generate_key_stats"):
        p.count_keys()
    jsonstr = p.to_json()
    opf = "profile-"+time.strftime("%Y%m%d-%H%M%S")+".json"
    if config.getboolean("output", "write_to_file"):
        write_json(jsonstr, filepath=os.path.join(scriptdir, "json", opf))
    else:
        print(jsonstr)
    if config.getboolean("output", "write_to_github"):
        post_gist(jsonstr, filename=opf)
开发者ID:oduwsdl,项目名称:archive_profiler,代码行数:32,代码来源:newmain.py


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