Пример #1
0
    def test_name(self):
        table = AddressTable(self.block_id)
        size = 100
        step = 3
        for i in range(0, size):
            if i % step == 0:
                table.create("res1", self.block_id + (1000 + i), i)

        for i in range(0, size):
            id_ = table.get_id('res1', i)
            self.assertEqual(id_, self.block_id + (1000 + (i / step) * step))
Пример #2
0
    def test_speed(self):
        reps = 100
        table = AddressTable(self.block_id)
        size = 100
        step = 3
        for i in range(0, size):
            if i % step == 0:
                table.create("res1", self.block_id + (1000 + i), i)

        t = time()
        for r in range(0, reps):
            for i in range(0, size):
                _ = table.get_id('res1', i)
            # print i, ID
        avg_time = (time() - t) / (size * r)
        self.assertLess(avg_time, 60e-6)  # less than 30 microseconds