コード例 #1
0
    def test_per_content(self):

        view = type('MockNetworkView', (), {})()

        c = collectors.CacheHitRatioCollector(view, content_hits=True)

        c.start_session(3.0, 'RECV', 1)
        c.cache_hit(1)
        c.end_session()

        c.start_session(4.0, 'RECV', 1)
        c.server_hit(2)
        c.end_session()

        c.start_session(5.0, 'RECV', 2)
        c.cache_hit(3)
        c.end_session()

        c.start_session(6.0, 'RECV', 2)
        c.server_hit(4)
        c.end_session()

        c.start_session(7.0, 'RECV', 2)
        c.server_hit(5)
        c.end_session()

        c.start_session(8.0, 'RECV', 2)
        c.server_hit(5)
        c.end_session()

        res = c.results()
        self.assertEqual({1: 0.5, 2: 0.25}, res['PER_CONTENT'])
コード例 #2
0
    def test_per_node(self):

        view = type('MockNetworkView', (), {})()

        c = collectors.CacheHitRatioCollector(view, per_node=True)

        c.start_session(3.0, 1, 'CONTENT')
        c.cache_hit(1)
        c.end_session()

        c.start_session(4.0, 1, 'CONTENT')
        c.cache_hit(1)
        c.end_session()

        c.start_session(5.0, 1, 'CONTENT')
        c.cache_hit(2)
        c.end_session()

        c.start_session(6.0, 1, 'CONTENT')
        c.cache_hit(3)
        c.end_session()

        c.start_session(7.0, 1, 'CONTENT')
        c.server_hit(4)
        c.end_session()

        res = c.results()
        self.assertEqual({
            1: 0.4,
            2: 0.2,
            3: 0.2
        }, res['PER_NODE_CACHE_HIT_RATIO'])
        self.assertEqual({4: 0.2}, res['PER_NODE_SERVER_HIT_RATIO'])
コード例 #3
0
ファイル: test_collectors.py プロジェクト: icarus-sim/icarus
    def test_per_content(self):

        view = type("MockNetworkView", (), {})()

        c = collectors.CacheHitRatioCollector(view, content_hits=True)

        c.start_session(3.0, "RECV", 1)
        c.cache_hit(1)
        c.end_session()

        c.start_session(4.0, "RECV", 1)
        c.server_hit(2)
        c.end_session()

        c.start_session(5.0, "RECV", 2)
        c.cache_hit(3)
        c.end_session()

        c.start_session(6.0, "RECV", 2)
        c.server_hit(4)
        c.end_session()

        c.start_session(7.0, "RECV", 2)
        c.server_hit(5)
        c.end_session()

        c.start_session(8.0, "RECV", 2)
        c.server_hit(5)
        c.end_session()

        res = c.results()
        assert {1: 0.5, 2: 0.25} == res["PER_CONTENT"]
コード例 #4
0
ファイル: test_collectors.py プロジェクト: icarus-sim/icarus
    def test_per_node(self):

        view = type("MockNetworkView", (), {})()

        c = collectors.CacheHitRatioCollector(view, per_node=True)

        c.start_session(3.0, 1, "CONTENT")
        c.cache_hit(1)
        c.end_session()

        c.start_session(4.0, 1, "CONTENT")
        c.cache_hit(1)
        c.end_session()

        c.start_session(5.0, 1, "CONTENT")
        c.cache_hit(2)
        c.end_session()

        c.start_session(6.0, 1, "CONTENT")
        c.cache_hit(3)
        c.end_session()

        c.start_session(7.0, 1, "CONTENT")
        c.server_hit(4)
        c.end_session()

        res = c.results()
        assert {1: 0.4, 2: 0.2, 3: 0.2} == res["PER_NODE_CACHE_HIT_RATIO"]
        assert {4: 0.2} == res["PER_NODE_SERVER_HIT_RATIO"]
コード例 #5
0
    def test_base(self):

        view = type('MockNetworkView', (), {})()

        c = collectors.CacheHitRatioCollector(view)

        c.start_session(3.0, 1, 'CONTENT')
        c.cache_hit(1)
        c.end_session()

        c.start_session(4.0, 1, 'CONTENT')
        c.server_hit(2)
        c.end_session()

        res = c.results()
        self.assertEqual(0.5, res['MEAN'])
コード例 #6
0
ファイル: test_collectors.py プロジェクト: icarus-sim/icarus
    def test_base(self):

        view = type("MockNetworkView", (), {})()

        c = collectors.CacheHitRatioCollector(view)

        c.start_session(3.0, 1, "CONTENT")
        c.cache_hit(1)
        c.end_session()

        c.start_session(4.0, 1, "CONTENT")
        c.server_hit(2)
        c.end_session()

        res = c.results()
        assert 0.5 == res["MEAN"]