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


Python Repo.add_content_object_to_repo方法代码示例

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


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

示例1: BenchmarkRepo

# 需要导入模块: from repo import Repo [as 别名]
# 或者: from repo.Repo import add_content_object_to_repo [as 别名]
class BenchmarkRepo(object):

    def __init__(self, clear=False):
        self.repo = Repo(clear=clear)

    def benchmark_write(self):
        name = "/ndn/ucla.edu/bms/building:melnitz/room:1451/seg0"
        content = "melnitz.1451.seg0"
        data = self.repo.wrap_content(name, content)
        data_size = getsizeof(data)

        volume = 0
        start_time = datetime.now()
        for i in range(100):
            self.repo.add_content_object_to_repo(name, data)
            volume += data_size
        finish_time = datetime.now()
        duration = finish_time - start_time
        print duration, volume

    def benchmark_read(self):
        # the graph db is queried 2 times per read if does not 
        # apply selectors. otherwise 4 times queries are needed
        name = "/ndn/ucla.edu/bms/building:melnitz/room:1451/seg0"
        content = "melnitz.1451.seg0"
        interest = Interest(Name(name))
        data = self.repo.wrap_content(name, content)
        data_size = getsizeof(data)

        volume = 0
        start_time = datetime.now()
        for i in range(1):
            self.repo.extract_from_repo(interest)
            volume += data_size
        finish_time = datetime.now()
        duration = finish_time - start_time
        print duration, volume

    def run_benchmark(self):
#        self.benchmark_write()
        self.benchmark_read()
开发者ID:remap,项目名称:BMS-REPO,代码行数:43,代码来源:benchmark.py


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