コード例 #1
0
ファイル: benchmark.py プロジェクト: remap/BMS-REPO
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()